Пример #1
0
static void 
ActiveBox_ExecUpdate(LCUI_Widget *widget)
/* 功能:更新ActiveBox部件内显示的图像 */
{
	LCUI_Rect rect;
	LCUI_Frames *frames;
	LCUI_Graph *frame_graph;
	LCUI_Pos pos;
	
	frames = ActiveBox_GetFrames( widget );
	frame_graph = Frames_GetGraphSlot( frames );
	pos = Align_Get_Pos( Widget_GetSize(widget), 
				frames->size, ALIGN_MIDDLE_CENTER);

	Widget_SetBackgroundTransparent( widget, TRUE );
	Widget_SetBackgroundImage( widget, frame_graph );
	Widget_SetBackgroundLayout( widget, LAYOUT_NONE );
	rect.x = pos.x;
	rect.y = pos.y;
	rect.width = frame_graph->width;
	rect.height = frame_graph->height;
	Widget_InvalidArea( widget, rect );
}
Пример #2
0
TextLayer_Draw( LCUI_Widget *widget, LCUI_TextLayer *layer, int mode )
/* 将文本图层绘制到目标部件的图层上 */
{
	LCUI_Rect area;
	LCUI_Pos pos, mix_pos;
	LCUI_BOOL draw_all = FALSE, redraw_row;
	int i, j, n, rows, size;
	LCUI_RGB color;
	LCUI_Graph slot, *graph;
	LCUI_CharData *p_data;
	Text_RowData *p_row;
	
	//clock_t start;
	//start = clock();
	//_DEBUG_MSG("enter\n");
	
	graph = Widget_GetSelfGraph( widget );
	/* 如果文本缓存区内有数据 */
	if( layer->need_proc_buff ) {
		__TextLayer_Text( layer );
		layer->need_proc_buff = FALSE;
	}
	/* 如果需要滚动图层 */
	if( layer->need_scroll_layer ) {
		layer->need_scroll_layer = FALSE;
		//_DEBUG_MSG("layer->need_scroll_layer\n");
		/* 根据之前记录的偏移坐标,刷新文本图层 */
		__TextLayer_OldArea_Erase( layer, Widget_GetSelfGraph( widget ) );
		draw_all = TRUE;
	}
	
	//_DEBUG_MSG("1, use time: %ld\n", clock() - start );
	//start = clock();
	
	Graph_Init( &slot );
	/* 先处理需要清空的区域 */
	n = Queue_GetTotal( &layer->clear_area ); 
	for(i=0; i<n; ++i) { 
		RectQueue_Get( &area, 0 , &layer->clear_area ); 
		area.x += layer->offset_pos.x;
		area.y += layer->offset_pos.y;
		Queue_Delete( &layer->clear_area, 0 );
		Graph_Quote( &slot, graph, area );
		/* 将该区域的alpha通道填充为0 */
		Graph_FillAlpha( &slot, 0 );
		Widget_InvalidArea( widget, area ); 
		//printf("refresh area: %d,%d,%d,%d\n",
		//area.x, area.y, area.width, area.height);
	}
	//_DEBUG_MSG("2, use time: %ld\n", clock() - start );
	//start = clock();
	/* 开始绘制文本位图至目标图层上 */
	rows = Queue_GetTotal( &layer->rows_data ); 
	for(pos.y=layer->offset_pos.y,i=0; i<rows; ++i) {
		redraw_row = FALSE;
		p_row = Queue_Get( &layer->rows_data, i );
		if( !p_row ) {
			continue;
		}
		n = Queue_GetTotal( &p_row->string );
		/* 如果当前字的位图的Y轴跨距不在有效绘制区域内 */
		if( pos.y + p_row->max_size.h <= 0 ) {
			pos.y += p_row->max_size.h;
			continue;
		}
		for(pos.x=layer->offset_pos.x,j=0; j<n; ++j) {
			/* 如果设置了屏蔽符 */
			p_data = Queue_Get( &p_row->string, j ); 
			if( !p_data ) {
				continue;
			}
			
			if( layer->password_char.char_code > 0 ) {
				layer->password_char.need_update = p_data->need_update;
				p_data = &layer->password_char;
			}
			/* 如果当前字的位图的X轴跨距不在有效绘制区域内 */
			if( pos.x + p_data->bitmap->advance.x <= 0) {
				pos.x += p_data->bitmap->advance.x;
				continue;
			}
			/* 获取该字体位图的大致尺寸 */
			if( p_data->data ) {
				size = p_data->data->pixel_size;
				size += 2;
				color = p_data->data->fore_color;
			} else {
				size = layer->default_data.pixel_size + 2; 
				color = layer->default_data.fore_color;
			}
			/* 如果字体位图已标记更新,则绘制它 */
			if( p_data->need_update || draw_all ) {
				p_data->need_update = FALSE;
				if( !redraw_row ) {
					area.x = pos.x;
					area.height = p_row->max_size.h;
					redraw_row = TRUE;
				}
				mix_pos.x = pos.x + p_data->bitmap->left;
				mix_pos.y = pos.y + p_row->max_size.h-1;
				mix_pos.y -= p_data->bitmap->top;
				/* 贴上字体位图 */
				FontBMP_Mix( graph, mix_pos,
					p_data->bitmap, color, mode );
			}
			pos.x += p_data->bitmap->advance.x;
			if( pos.x > widget->size.w ) {
				break;
			}
		}
		if(redraw_row) {
			area.y = pos.y;
			area.width = pos.x - area.x;
			//_DEBUG_MSG("area:%d,%d,%d,%d\n", 
			//area.x, area.y, area.width, area.height);
			Widget_InvalidArea( widget, area );
		}
		pos.y += p_row->max_size.h;
		if( pos.y > widget->size.h ) {
			break;
		}
	}
	//_DEBUG_MSG("3, use time: %ld\n", clock() - start );
	//_DEBUG_MSG("quit\n");
}