Ejemplo n.º 1
0
static void player_entry(void* parameter)
{
    rt_mq_t mq;
    rtgui_rect_t rect;

    mq = rt_mq_create("ply_ui", 256, 4, RT_IPC_FLAG_FIFO);
    rtgui_thread_register(rt_thread_self(), mq);

    /* create information timer */
    info_timer = rtgui_timer_create(RT_TICK_PER_SECOND, RT_TIMER_FLAG_PERIODIC, info_timer_timeout, RT_NULL);

    workbench = rtgui_workbench_create("main", "workbench");
    if (workbench == RT_NULL) return;
    rtgui_widget_set_event_handler(RTGUI_WIDGET(workbench), player_workbench_event_handler);

    /* add home view */
    home_view = rtgui_view_create("Home");
    rtgui_widget_set_event_handler(RTGUI_WIDGET(home_view), home_view_event_handler);

    rtgui_workbench_add_view(workbench, home_view);
    /* this view can be focused */
    RTGUI_WIDGET(home_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
    /* set widget focus */
    rtgui_widget_focus(RTGUI_WIDGET(home_view));

	rtgui_widget_get_rect(RTGUI_WIDGET(home_view), &rect);
	rect.x1 += 6; rect.y1 += 150 + 25;
	rect.x2 = rect.x1 + 228; rect.y2 = rect.y1 + 145;
	music_listbox = rtgui_listbox_create(RT_NULL, 0, &rect);
	/* none focusable widget */
	RTGUI_WIDGET(music_listbox)->flag &= ~RTGUI_WIDGET_FLAG_FOCUSABLE;
	RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(music_listbox)) = black;
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(music_listbox)) = white;
	rtgui_container_add_child(RTGUI_CONTAINER(home_view), RTGUI_WIDGET(music_listbox));
	rtgui_listbox_set_onitem(music_listbox, player_play_list_onitem);

    rtgui_view_show(home_view, RT_FALSE);

    /* add function view */
    rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
    function_view = rtgui_list_view_create(function_list,
                                           sizeof(function_list)/sizeof(struct rtgui_list_item),
                                           &rect,
										   RTGUI_LIST_VIEW_LIST);
    rtgui_workbench_add_view(workbench, RTGUI_VIEW(function_view));

    rtgui_workbench_event_loop(workbench);

    rtgui_thread_deregister(rt_thread_self());
    rt_mq_delete(mq);
}
Ejemplo n.º 2
0
static void info_entry(void* parameter)
{
	rt_mq_t mq;
	struct rtgui_view* view;
	struct rtgui_workbench* workbench;

	mq = rt_mq_create("qInfo", 256, 4, RT_IPC_FLAG_FIFO);
	rtgui_thread_register(rt_thread_self(), mq);

    network_image = rtgui_image_create_from_mem("xpm",
		(rt_uint8_t*)network_xpm, sizeof(network_xpm), RT_TRUE);
	workbench = rtgui_workbench_create("info", "workbench");
	if (workbench == RT_NULL) return;

	view = rtgui_view_create("view");
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
	rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler);

	rtgui_workbench_add_view(workbench, view);

	rtgui_view_show(view, RT_FALSE);

	rtgui_workbench_event_loop(workbench);

	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
Ejemplo n.º 3
0
static void _rtgui_fileview_constructor(rtgui_fileview_t *fview)
{
	/* set default widget rect and set event handler */
	rtgui_widget_set_event_handler(fview, rtgui_fileview_event_handler);
	rtgui_widget_set_onunfocus(fview, rtgui_fileview_onunfocus);

	RTGUI_WIDGET_FLAG(fview) |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	fview->first_item = 0;
	fview->now_item = 0;
	fview->item_count = 0;
	fview->item_per_page = 0;

	fview->current_dir = RT_NULL;
	fview->pattern = RT_NULL;
	RTGUI_WIDGET_BC(fview) = theme.blankspace;
	RTGUI_WIDGET_TEXTALIGN(fview) = RTGUI_ALIGN_CENTER_VERTICAL;
	
	if(theme.style == RTGUI_BORDER_UP)
		rtgui_widget_set_border_style(fview,RTGUI_BORDER_DOWN);
	else if(theme.style == RTGUI_BORDER_EXTRA)
		rtgui_widget_set_border_style(fview,RTGUI_BORDER_SUNKEN);

	fview->on_item = RT_NULL;
	fview->dlg = RT_NULL;

	if(file_image==RT_NULL)
		file_image = rtgui_image_create_from_mem("xpm",(rt_uint8_t*)file_xpm, sizeof(file_xpm), RT_TRUE);
	if(folder_image==RT_NULL)
		folder_image = rtgui_image_create_from_mem("xpm",(rt_uint8_t*)folder_xpm, sizeof(folder_xpm), RT_TRUE);
}
rtgui_view_t *demo_view_buffer_animation(rtgui_workbench_t* workbench)
{
	rtgui_view_t *view;

	view = demo_view(workbench, "DC 缓冲区动画");
	if (view != RT_NULL)
		rtgui_widget_set_event_handler(RTGUI_WIDGET(view), animation_event_handler);

	rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(view)), "缓冲动画", &text_rect);
	if (dc_buffer == RT_NULL)
	{
		rtgui_rect_t rect;

		rect.x1 = 0; rect.x2 = rtgui_rect_width(text_rect) + 2;
		rect.y1 = 0; rect.y2 = rtgui_rect_height(text_rect) + 2;

		/* 创建 DC Buffer,长 50,宽 50 */
		dc_buffer = rtgui_dc_buffer_create(rtgui_rect_width(rect), rtgui_rect_height(rect));
		RTGUI_DC_FC(dc_buffer) = RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view));
		rtgui_dc_fill_rect(dc_buffer, &rect);
		RTGUI_DC_FC(dc_buffer) = black;
		rect.x1 = 1; rect.y1 = 1;
		rtgui_dc_draw_text(dc_buffer, "缓冲动画", &rect);
	}

	/* 启动定时器以触发动画 */
	timer = rtgui_timer_create(1, RT_TIMER_FLAG_PERIODIC, timeout, (void*)view);
	rtgui_timer_start(timer);

	return view;
}
Ejemplo n.º 5
0
static void info_entry(void* parameter)
{
	rt_mq_t mq;
	struct rtgui_view* view;
	struct rtgui_workbench* workbench;

	mq = rt_mq_create("qInfo", 256, 4, RT_IPC_FLAG_FIFO);
	rtgui_thread_register(rt_thread_self(), mq);

	workbench = rtgui_workbench_create("info", "workbench");
	if(workbench == RT_NULL) 
        return;

	view = rtgui_view_create("view");
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
    RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(view)) = black;
	rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler);

	rtgui_workbench_add_view(workbench, view);
    /* this view can be focused */
    RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
    /* set widget focus */
    rtgui_widget_focus(RTGUI_WIDGET(view));    

	rtgui_view_show(view, RT_FALSE);

	rtgui_workbench_event_loop(workbench);

	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
Ejemplo n.º 6
0
static void today_entry(void* parameter)
{
	rt_mq_t mq;
	struct rtgui_view* view;
	struct rtgui_workbench* workbench;

	mq = rt_mq_create("qToday", 256, 4, RT_IPC_FLAG_FIFO);
	rtgui_thread_register(rt_thread_self(), mq);

    /* create background image */
    background = rtgui_image_create_from_file("png",
        "/bg.png", RT_FALSE);

	workbench = rtgui_workbench_create("main", "workbench");
	if (workbench == RT_NULL) return;

	view = rtgui_view_create("Today");
	rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler);

	rtgui_workbench_add_view(workbench, view);

	rtgui_view_show(view);

	rtgui_workbench_event_loop(workbench);

	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
Ejemplo n.º 7
0
rtgui_view_t *demo_gui_benchmark(rtgui_view_t* parent_view)
{
	srand(100);
	view = demo_view_create(parent_view, "绘图测试");
	rtgui_widget_set_event_handler(view, benchmark_event_handler);

	return view;
}
Ejemplo n.º 8
0
static void _rtgui_label_constructor(rtgui_label_t *label)
{
    /* init widget and set event handler */
    rtgui_widget_set_event_handler(RTGUI_WIDGET(label), rtgui_label_event_handler);

    /* set field */
    label->text = RT_NULL;
}
Ejemplo n.º 9
0
static void _rtgui_staticline_constructor(rtgui_staticline_t *staticline)
{
	/* init widget and set event handler */
	rtgui_rect_t rect = {0, 0, 100, 2};

	rtgui_widget_set_rect(RTGUI_WIDGET(staticline), &rect);
	staticline->orient= RTGUI_HORIZONTAL;

	rtgui_widget_set_event_handler(RTGUI_WIDGET(staticline), rtgui_staticline_event_handler);
}
Ejemplo n.º 10
0
/* 创建用于DC操作演示用的视图 */
rtgui_view_t *demo_view_dc(rtgui_workbench_t* workbench)
{
	rtgui_view_t *view;

	view = demo_view(workbench, "DC Demo");
	if (view != RT_NULL)
		/* 设置成自己的事件处理函数 */
		rtgui_widget_set_event_handler(RTGUI_WIDGET(view), dc_event_handler);

	return view;
}
/* 创建用于DC操作演示用的视图 */
rtgui_view_t *demo_view_instrument_panel(rtgui_workbench_t* workbench)
{
    rtgui_view_t *view;

    view = demo_view(workbench, "instrument panel Demo");
    if (view != RT_NULL)
        /* 设置成自己的事件处理函数 */
        rtgui_widget_set_event_handler(RTGUI_WIDGET(view), instrument_panel_event_handler);

    return view;
}
Ejemplo n.º 12
0
static void _rtgui_workbench_constructor(rtgui_workbench_t *workbench)
{
	/* set event handler */
	rtgui_widget_set_event_handler(RTGUI_WIDGET(workbench), rtgui_workbench_event_handler);

	/* set attributes */
	workbench->flag 		= RTGUI_WORKBENCH_FLAG_DEFAULT;
	workbench->panel 		= RT_NULL;
	workbench->title 		= RT_NULL;
	workbench->current_view = RT_NULL;
	workbench->modal_code 	= RTGUI_MODAL_OK;
	workbench->modal_widget = RT_NULL;
}
Ejemplo n.º 13
0
static void _rtgui_checkbox_constructor(rtgui_checkbox_t *box)
{
	/* init widget and set event handler */
	RTGUI_WIDGET(box)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	rtgui_widget_set_event_handler(RTGUI_WIDGET(box), rtgui_checkbox_event_handler);

	/* set status */
	box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
	box->on_button = RT_NULL;

	/* set default gc */
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
}
Ejemplo n.º 14
0
static void _rtgui_progressbar_constructor(rtgui_progressbar_t *bar)
{
	rtgui_rect_t rect = {0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT};

	rtgui_widget_set_event_handler(RTGUI_WIDGET(bar), rtgui_progressbar_event_handler);
	rtgui_widget_set_rect(RTGUI_WIDGET(bar), &rect);

	bar->orient = RTGUI_HORIZONTAL;
	bar->range = RTGUI_PROGRESSBAR_DEFAULT_RANGE;
	bar->position = 0;

	/* set gc */
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(bar)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
}
Ejemplo n.º 15
0
static void _rtgui_listbox_constructor(struct rtgui_listbox *box)
{
	/* set default widget rect and set event handler */
	rtgui_widget_set_event_handler(RTGUI_WIDGET(box),rtgui_listbox_event_handler);

	RTGUI_WIDGET(box)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	box->current_item = 0;
	box->items_count = 0;
	box->page_items = 1;
	box->on_item = 0;

	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(box)) = white;
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_CENTER_VERTICAL;
}
Ejemplo n.º 16
0
static void _rtgui_terminal_constructor(rtgui_terminal_t *tma)
{
	/* init widget and set event handler */
	rtgui_widget_set_event_handler(tma, rtgui_terminal_event_handler);
	RTGUI_WIDGET_TEXTALIGN(tma) = RTGUI_ALIGN_LEFT;
	RTGUI_WIDGET_FLAG(tma) |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	/* set field */
	tma->item_count = 0;
	tma->first_item = 0;
	tma->now_item = 0;
	tma->old_item = 0;
	tma->item_per_page = 0;

	tma->lines = RT_NULL;
}
Ejemplo n.º 17
0
static void _rtgui_combobox_constructor(rtgui_combobox_t *box)
{
	rtgui_rect_t rect = {0, 0, RTGUI_COMBOBOX_WIDTH, RTGUI_COMBOBOX_HEIGHT};

	/* init widget and set event handler */
	rtgui_widget_set_event_handler(RTGUI_WIDGET(box), rtgui_combobox_event_handler);
	rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);

	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_CENTER_VERTICAL;

	box->pd_pressed = RT_FALSE;
	box->current_item = 0;
	box->on_selected = RT_NULL;
	box->pd_win    = RT_NULL;
}
Ejemplo n.º 18
0
static void _rtgui_radiobox_constructor(rtgui_radiobox_t *radiobox)
{
	rtgui_rect_t rect = {0, 0, RTGUI_RADIOBOX_DEFAULT_WIDTH, RTGUI_RADIOBOX_DEFAULT_HEIGHT};

	/* init widget and set event handler */
	RTGUI_WIDGET(radiobox)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(radiobox)) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
	rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
	rtgui_widget_set_event_handler(RTGUI_WIDGET(radiobox), rtgui_radiobox_event_handler);

	/* set proper of control */
	radiobox->items = RT_NULL;
	radiobox->item_count = 0;
	radiobox->item_selection = -1;
	radiobox->orient = RTGUI_HORIZONTAL;
}
Ejemplo n.º 19
0
static void _rtgui_form_constructor(struct rtgui_form *form)
{
	rt_memset(form, 0, sizeof(*form));

	/* form中元素已全部清零, 下面只需要对初值不为零的进行初始化 */
	/* set default widget rect and set event handler */
	rtgui_widget_set_event_handler(RTGUI_WIDGET(form),rtgui_form_event_handler);

	RTGUI_WIDGET(form)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	form->form_rect.x1 = ~0;

	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(form)) = white;
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(form))  = RTGUI_ALIGN_CENTER_VERTICAL;

	return;
}
Ejemplo n.º 20
0
static void _rtgui_listctrl_constructor(struct rtgui_listctrl *ctrl)
{
	/* set default widget rect and set event handler */
	rtgui_widget_set_event_handler(RTGUI_WIDGET(ctrl),rtgui_listctrl_event_handler);

	RTGUI_WIDGET(ctrl)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	ctrl->current_item = -1;
	ctrl->items_count = 0;
	ctrl->page_items = 0;
	ctrl->on_item = 0;
	ctrl->on_item_draw = RT_NULL;

	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(ctrl)) = white;
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(ctrl)) = RTGUI_ALIGN_CENTER_VERTICAL;
}
Ejemplo n.º 21
0
Archivo: edit.c Proyecto: amsl/RTGUI
void _rtgui_edit_constructor(struct rtgui_edit *edit)
{
	rtgui_rect_t font_rect;
	RTGUI_WIDGET_FLAG(edit) |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	rtgui_widget_set_event_handler(edit, rtgui_edit_event_handler);
	rtgui_widget_set_onfocus(edit, rtgui_edit_onfocus);
	rtgui_widget_set_onunfocus(edit, rtgui_edit_onunfocus);
	
	RTGUI_WIDGET_FC(edit) = theme.foreground;
	RTGUI_WIDGET_BC(edit) = theme.blankspace;
	/* set default text align */
	RTGUI_WIDGET_TEXTALIGN(edit) = RTGUI_ALIGN_CENTER_VERTICAL;
	/* set proper of control */
	edit->caret_timer = RT_NULL;
	edit->caret = RT_NULL;

	edit->tabsize = 4;
	edit->margin  = 1;
	edit->max_rows = edit->max_cols = 0;
	edit->visual.x = edit->visual.y = 0;
	edit->upleft.x = edit->upleft.y = 0;
	edit->row_per_page = edit->col_per_page = 0;

	edit->update_buf = RT_NULL;
	edit->flag = RTGUI_EDIT_NONE;
#ifdef RTGUI_EDIT_USING_SCROLL
	edit->flag |= RTGUI_EDIT_VSCROLL;
	edit->flag |= RTGUI_EDIT_HSCROLL;
#endif
	/* allocate default line buffer */
	edit->bzsize = 16;
	
	rtgui_font_get_metrics(RTGUI_WIDGET_FONT(edit), "H", &font_rect);
	edit->font_width = rtgui_rect_width(font_rect);
	edit->font_height = rtgui_rect_height(font_rect);

	edit->dbl_buf = rtgui_dc_buffer_create(edit->font_width*2+1, edit->font_height+1);
	
	edit->head = RT_NULL;
	edit->tail = RT_NULL;
	edit->first_line = RT_NULL;
#ifdef RTGUI_EDIT_USING_SCROLL	
	edit->hscroll = RT_NULL;
	edit->vscroll = RT_NULL;
#endif
}
Ejemplo n.º 22
0
static void _rtgui_combo_constructor(rtgui_combo_t *cbo)
{
	RTGUI_WIDGET_FLAG(cbo) |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	cbo->style = RTGUI_COMBO_STYLE_DOWNARROW_UP;
	cbo->lbox = RT_NULL;
	cbo->tbox = RT_NULL;
	if(theme.style == RTGUI_BORDER_UP)
		rtgui_widget_set_border_style(cbo,RTGUI_BORDER_DOWN);
	else if(theme.style == RTGUI_BORDER_EXTRA)
		rtgui_widget_set_border_style(cbo,RTGUI_BORDER_SUNKEN);
	rtgui_widget_set_event_handler(cbo, rtgui_combo_event_handler);

	RTGUI_WIDGET_BC(cbo) = theme.blankspace;
	/* set default text align */
	RTGUI_WIDGET_TEXTALIGN(cbo) = RTGUI_ALIGN_CENTER_VERTICAL;
	cbo->on_selected = RT_NULL;
}
Ejemplo n.º 23
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);
}
Ejemplo n.º 24
0
rtgui_view_t *picture_view_create_view_file(struct rtgui_workbench* workbench,
	const char* filename)
{
	strcpy(current_fn, filename);

    /* create picture view */
    picture_view = rtgui_view_create("Picture Presentation");
	rtgui_widget_set_event_handler(RTGUI_WIDGET(picture_view),
        picture_view_event_handler);

	rtgui_workbench_add_view(workbench, picture_view);
	/* this view can be focused */
	RTGUI_WIDGET(picture_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	view_mode = VIEW_SINGLE_MODE;

	return picture_view;
}
Ejemplo n.º 25
0
rtgui_view_t *picture_view_create(struct rtgui_workbench* workbench)
{
    /* create picture view */
    picture_view = rtgui_view_create("Picture Presentation");
	rtgui_widget_set_event_handler(RTGUI_WIDGET(picture_view),
        picture_view_event_handler);

	rtgui_workbench_add_view(workbench, picture_view);
	/* this view can be focused */
	RTGUI_WIDGET(picture_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	
	/* show next picture */
	picture_show_next();
	
	view_mode = VIEW_DIR_MODE;

	return picture_view;
}
Ejemplo n.º 26
0
static void _rtgui_button_constructor(rtgui_button_t *button)
{
	/* init widget and set event handler */
	RTGUI_WIDGET(button)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	rtgui_widget_set_event_handler(RTGUI_WIDGET(button), rtgui_button_event_handler);

	/* un-press button */
	button->flag = 0;

	/* set flag and on_button event handler */
	button->pressed_image = RT_NULL;
	button->unpressed_image = RT_NULL;
	button->on_button = RT_NULL;

	/* set gc */
	RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(button)) = default_foreground;
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button)) = RTGUI_RGB(212, 208, 200);
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(button)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
}
Ejemplo n.º 27
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);
}
Ejemplo n.º 28
0
static void _rtgui_list_view_constructor(struct rtgui_list_view *view)
{
	/* default rect */
	struct rtgui_rect rect = {0, 0, 200, 200};

	/* set default widget rect and set event handler */
	rtgui_widget_set_event_handler(RTGUI_WIDGET(view),rtgui_list_view_event_handler);
	rtgui_widget_set_rect(RTGUI_WIDGET(view), &rect);

	RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	view->flag = RTGUI_LIST_VIEW_LIST;
	view->current_item = 0;
	view->items_count = 0;
	view->page_items = 0;

	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(view)) = RTGUI_ALIGN_CENTER_VERTICAL;
}
Ejemplo n.º 29
0
static void _rtgui_win_constructor(rtgui_win_t *win)
{
	/* init window attribute */
	win->on_activate	= RT_NULL;
	win->on_deactivate	= RT_NULL;
	win->on_close		= RT_NULL;
	win->title			= RT_NULL;
	win->modal_code		= RTGUI_MODAL_OK;
	win->modal_widget	= RT_NULL;

	/* set window hide */
	RTGUI_WIDGET_HIDE(RTGUI_WIDGET(win));

	/* set window style */
	win->style = RTGUI_WIN_STYLE_DEFAULT;
	rtgui_widget_set_event_handler(RTGUI_WIDGET(win), rtgui_win_event_handler);

	/* init user data */
	win->user_data = 0;
}
Ejemplo n.º 30
0
rtgui_view_t *device_view_create(rtgui_workbench_t* workbench)
{
	if (device_view != RT_NULL)
	{
		rtgui_view_show(device_view, RT_FALSE);
	}
	else
	{
		/* create a view */
		device_view = rtgui_view_create("Device Info");
		/* set view event handler */
		rtgui_widget_set_event_handler(RTGUI_WIDGET(device_view), view_event_handler);
		/* this view can be focused */
		RTGUI_WIDGET(device_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	
		/* add view to workbench */
		rtgui_workbench_add_view(workbench, device_view);
	}
	
	return device_view;
}