コード例 #1
0
static void priv_page(rtgui_widget_t *widget)
{
    struct rtgui_dc *dc;
    if (app_list->current_page == 0)
    {
        return;
    }
    app_list->current_page--;
    while ((app_list->current_page * 480) < app_list->listdisp_point.x)
    {

        app_list->listdisp_point.x -= 40;
        app_list->bgdisp_point.x -= 10;
        dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(widget));
        rtgui_dc_blit(app_list->bg_buffer, &app_list->bgdisp_point,
                      dc, &app_list->rect);
        rtgui_dc_blit(app_list->view_buffer, &app_list->listdisp_point,
                      dc, &app_list->view_rect);
        rtgui_dc_blit(app_list->pm_buffer, RT_NULL, dc, &app_list->pm_rect);
        rtgui_dc_end_drawing(dc);
    }
    app_list_pagemark_change(app_list);
    dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(widget));
    rtgui_dc_blit(app_list->pm_buffer, RT_NULL, dc, &app_list->pm_rect);
    rtgui_dc_end_drawing(dc);
}
コード例 #2
0
static void on_draw(rtgui_widget_t *widget)
{
    struct rtgui_dc *dc;
    dc = rtgui_dc_begin_drawing(widget);
    rtgui_dc_blit(app_list->bg_buffer, &app_list->bgdisp_point,
                  dc, &app_list->rect);
    rtgui_dc_blit(app_list->view_buffer, &app_list->listdisp_point,
                  dc, &app_list->view_rect);
    rtgui_dc_blit(app_list->pm_buffer, RT_NULL, dc, &app_list->pm_rect);
    rtgui_dc_end_drawing(dc);
}
コード例 #3
0
static rt_bool_t animation_event_handler(rtgui_widget_t* widget, rtgui_event_t *event)
{
	if (event->type == RTGUI_EVENT_PAINT)
	{
		struct rtgui_dc* dc;
		rtgui_rect_t rect;

		/* 因为用的是demo view,上面本身有一部分控件,所以在绘图时先要让demo view先绘图 */
		rtgui_view_event_handler(widget, event);

		/* 获得控件所属的DC */
		dc = rtgui_dc_begin_drawing(widget);
		if (dc == RT_NULL) /* 如果不能正常获得DC,返回(如果控件或父控件是隐藏状态,DC是获取不成功的) */
			return RT_FALSE;

        /* 获得demo view允许绘图的区域 */
        demo_view_get_logic_rect(RTGUI_VIEW(widget), &rect);

		/* 绘图 */
		rect = text_rect;
		rtgui_rect_inflate(&rect, +1);
		rtgui_dc_blit(dc_buffer, NULL, dc, &rect);

		/* 绘图完成 */
		rtgui_dc_end_drawing(dc);
	}
	else
	{
		/* 调用默认的事件处理函数 */
		return rtgui_view_event_handler(widget, event);
	}

	return RT_FALSE;
}
コード例 #4
0
/*
 * view的事件处理函数
 */
static rt_bool_t dc_buffer_event_handler(PVOID wdt, rtgui_event_t *event)
{

	/* 仅对PAINT事件进行处理 */
	if (event->type == RTGUI_EVENT_PAINT) {
		struct rtgui_dc* dc;
		rtgui_rect_t rect;

		/*
		 * 因为用的是demo view,上面本身有一部分控件,所以在绘图时先要让demo view
		 * 先绘图
		 */
		rtgui_view_event_handler(wdt, event);

		/* 获得控件所属的DC */
		dc = rtgui_dc_begin_drawing(wdt);
		/* 如果不能正常获得DC,返回(如果控件或父控件是隐藏状态,DC是获取不成功的) */
		if (dc == RT_NULL)
			return RT_FALSE;
		rtgui_widget_get_rect(wdt, &rect);
		rect.x1 += 10;
		rect.y1 += 40;
		rtgui_dc_blit(dc_buffer, NULL, dc, &rect);

		/* 绘图完成 */
		rtgui_dc_end_drawing(dc);
	} else {
		/* 其他事件,调用默认的事件处理函数 */
		return rtgui_view_event_handler(wdt, event);
	}

	return RT_FALSE;
}
コード例 #5
0
static void timeout(struct rtgui_timer* timer, void* parameter)
{
    rtgui_dc_t* dc;
    rtgui_rect_t rect;
    rtgui_view_t *view;

    /* 控件(view)通过parameter参数传递给定时器 */
    view = (rtgui_view_t*)parameter;

    /* 获得控件所属的DC */
    dc = rtgui_dc_begin_drawing(view);
    if (dc == RT_NULL) /* 如果不能正常获得DC,返回(如果控件或父控件是隐藏状态,DC是获取不成功的) */
        return ;

    /* 获得demo view允许绘图的区域,主要用于判断边界 */
    rtgui_widget_get_rect(view, &rect);
    rtgui_rect_inflate(&rect, -5);
    rect.y1 += 35;

    /* 判断是否是第一次绘图 */
    if ((text_rect.x1 == 0) && (text_rect.y1 == 0))
    {
        rtgui_rect_moveto(&text_rect, rect.x1, rect.y1);
    }

    /* 设置dx和dy */
    if (text_rect.x2 >= rect.x2) dx = -1;
    if (text_rect.x1 < rect.x1)  dx = 1;
    if (text_rect.y2 >= rect.y2) dy = -1;
    if (text_rect.y1 < rect.y1) dy = 1;

    /* 移动文本框的位置 */
    text_rect.x1 += dx;
    text_rect.x2 += dx;
    text_rect.y1 += dy;
    text_rect.y2 += dy;

    /* 绘图 */
    rect = text_rect;
    rect.x2 += 2;
    rect.y2 += 2;
    rtgui_dc_blit(dc_buffer, NULL, dc, &rect);

    /* 绘图完成 */
    rtgui_dc_end_drawing(dc);
}
コード例 #6
0
/*
 * view的事件处理函数
 */
static rt_bool_t dc_buffer_event_handler(struct rtgui_object* object, rtgui_event_t *event)
{
	struct rtgui_widget *widget = RTGUI_WIDGET(object);

	/* 仅对PAINT事件进行处理 */
	if (event->type == RTGUI_EVENT_PAINT)
	{
		struct rtgui_dc* dc;
		rtgui_rect_t rect;

		/*
		 * 因为用的是demo view,上面本身有一部分控件,所以在绘图时先要让demo view
		 * 先绘图
		 */
		rtgui_container_event_handler(object, event);

		/* 获得控件所属的DC */
		dc = rtgui_dc_begin_drawing(widget);
		/* 如果不能正常获得DC,返回(如果控件或父控件是隐藏状态,DC是获取不成功的) */
		if (dc == RT_NULL)
			return RT_FALSE;

		/* 获得demo view允许绘图的区域 */
		demo_view_get_logic_rect(RTGUI_CONTAINER(widget), &rect);

		rect.x1 += 10;
		rect.y1 += 10;
		rtgui_dc_blit(dc_buffer, NULL, dc, &rect);

		/* 绘图完成 */
		rtgui_dc_end_drawing(dc);
	}
	else
	{
		/* 其他事件,调用默认的事件处理函数 */
		return rtgui_container_event_handler(object, event);
	}

	return RT_FALSE;
}
コード例 #7
0
ファイル: edit.c プロジェクト: amsl/RTGUI
void rtgui_edit_ondraw(struct rtgui_edit *edit)
{
	rtgui_rect_t rect, r;
	struct rtgui_dc *dc;
#ifdef RTGUI_EDIT_USING_SCROLL
	int hscroll_flag=0;
	int vscroll_flag=0;
#endif
	
	RT_ASSERT(edit != RT_NULL);

	dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(edit));
	if(dc == RT_NULL) return;

	/* get widget rect */
	rtgui_widget_get_rect(RTGUI_WIDGET(edit), &rect);
	rtgui_rect_inflate(&rect, -RTGUI_WIDGET_BORDER_SIZE(edit));

	/* fill widget rect with edit background color */
	RTGUI_DC_BC(dc) = RTGUI_WIDGET_BC(edit);
	rtgui_dc_fill_rect(dc, &rect);

	rtgui_rect_inflate(&rect, RTGUI_WIDGET_BORDER_SIZE(edit));
	/* draw border */
	rtgui_dc_draw_border(dc, &rect, RTGUI_WIDGET_BORDER_STYLE(edit));

	rtgui_rect_inflate(&rect, -(edit->margin + RTGUI_WIDGET_BORDER_SIZE(edit)));

#ifdef RTGUI_EDIT_USING_SCROLL
	if(edit->vscroll && !RTGUI_WIDGET_IS_HIDE(edit->vscroll))
	{
		rect.x2 = rect.x2 - rtgui_rect_width(edit->vscroll->parent.extent);
	}
	if(edit->hscroll && !RTGUI_WIDGET_IS_HIDE(edit->hscroll))
	{
		rect.y2 = rect.y2 - rtgui_rect_height(edit->hscroll->parent.extent);
	}
#endif
	r = rect;
	
	/* draw text */
	if(edit->head != RT_NULL)
	{
		struct edit_line *line = edit->first_line;
		int num=0;
		
		rect.y2 = rect.y1 + edit->item_height;
		while(line)
		{
			rt_uint32_t tmp_pos=0, ofs;
			char *str = line->text+edit->upleft.x;
			
			if(edit->upleft.x < line->len)
			{
				rtgui_point_t p = edit->visual;
				edit->visual.x = 0;
				identify_double_byte(edit, line, EDIT_IDENT_DIR_LEFT, &tmp_pos);
				ofs = tmp_pos % 2;
				if(ofs == 1)
				{
					char dbl_bmp[3];
					rtgui_point_t pot = {0};
					rtgui_rect_t r = {0};
					
					pot.x = edit->font_width;
					r.x2 = edit->font_width*2;
					r.y2 = edit->font_height;
					dbl_bmp[0] = *(str-1);
					dbl_bmp[1] = *str;
					dbl_bmp[2] = '\0';
					RTGUI_DC_BC(edit->dbl_buf) = RTGUI_WIDGET_BC(edit);
					rtgui_dc_fill_rect(edit->dbl_buf, &r);
					RTGUI_DC_FC(edit->dbl_buf) = RTGUI_WIDGET_FC(edit);
					rtgui_dc_draw_text(edit->dbl_buf, dbl_bmp, &r);
					rtgui_dc_blit(edit->dbl_buf, pot.x, pot.y, dc, rect.x1, rect.y1, 
						edit->font_width, edit->font_height);
				}
				rect.x1 += ofs * edit->font_width;
				rtgui_dc_draw_text(dc, line->text+edit->upleft.x+ofs, &rect);
				rect.x1 -= ofs * edit->font_width;
				edit->visual = p;
			}
			
			line = line->next;
			rect.y1 += edit->item_height;
			if((rect.y1 + edit->item_height) < r.y2)
				rect.y2 = rect.y1 + edit->item_height;
			else
				rect.y2 = r.y2;
			
			if(num++ >= edit->row_per_page)
				break;
		}
	}

#ifdef RTGUI_EDIT_USING_SCROLL
	if(edit->hscroll && !RTGUI_WIDGET_IS_HIDE(edit->hscroll))
	{
		hscroll_flag = 1;
		rtgui_scrollbar_ondraw(edit->hscroll);
	}
	if(edit->vscroll && !RTGUI_WIDGET_IS_HIDE(edit->vscroll))
	{
		vscroll_flag = 1;
		rtgui_scrollbar_ondraw(edit->vscroll);
	}

	if(hscroll_flag && vscroll_flag)
	{
		rtgui_color_t _bc;
		rtgui_widget_get_rect(RTGUI_WIDGET(edit), &rect);
		rect.x1 = rect.x2-RTGUI_WIDGET_BORDER_SIZE(edit);
		rect.y1 = rect.y2-RTGUI_WIDGET_BORDER_SIZE(edit);
		_bc = RTGUI_DC_BC(dc);
		RTGUI_DC_BC(dc) = theme.background;
		rtgui_dc_fill_rect(dc,&rect);
		RTGUI_DC_BC(dc) = _bc;
	}
#endif
	rtgui_dc_end_drawing(dc);
}