コード例 #1
0
/** 重新载入各个文字的字体位图 */
void TextLayer_ReloadCharBitmap( LCUI_TextLayer layer )
{
	int row, col;
	for( row = 0; row < layer->rowlist.length; ++row ) {
		TextRow txtrow = layer->rowlist.rows[row];
		for( col = 0; col < txtrow->length; ++col ) {
			TextChar txtchar = txtrow->string[col];
			TextChar_UpdateBitmap( txtchar, &layer->text_style );
		}
		TextLayer_UpdateRowSize( layer, txtrow );
	}
}
コード例 #2
0
ファイル: textlayer.c プロジェクト: oyjGit/LCUI
/** 重新载入各个文字的字体位图 */
void TextLayer_ReloadCharBitmap( LCUI_TextLayer* layer )
{
	int row, col;
	TextCharData* p_char;
	TextRowData* p_row;

	for( row=0; row<layer->row_list.rows; ++row ) {
		p_row = layer->row_list.rowdata[row];
		for( col=0; col<p_row->string_len; ++col ) {
			p_char = p_row->string[col];
			TextChar_UpdateBitmap( p_char, &layer->text_style );
			if( !p_char->bitmap ) {
				continue;
			}
		}
		TextRow_UpdateSize( p_row, layer->text_style.pixel_size );
	}
}
コード例 #3
0
ファイル: textlayer.c プロジェクト: oyjGit/LCUI
/** 对文本进行预处理 */ 
static int TextLayer_ProcessText( LCUI_TextLayer *layer, const wchar_t *wstr,
			TextAddType add_type, LCUI_StyleTagStack *tag_stack )
{
	EOLChar eol;
	int cur_col, cur_row, start_row, ins_x, ins_y;
	const wchar_t *p_end, *p, *pp;
	TextRowData *p_row;
	TextCharData char_data;
	LCUI_StyleTagStack tmp_tag_stack;
	LCUI_BOOL is_tmp_tag_stack, need_typeset, rect_has_added;

	if( !wstr ) {
		return -1;
	}
	is_tmp_tag_stack = FALSE;
	need_typeset = FALSE;
	rect_has_added = FALSE;
	/* 如果是将文本追加至文本末尾 */
	if( add_type == TEXT_ADD_TYPE_APPEND ) {
		if( layer->row_list.rows > 0 ) {
			cur_row = layer->row_list.rows - 1;
		} else {
			cur_row = 0;
		}
		p_row = TextRowList_GetRow( &layer->row_list, cur_row );
		if( !p_row ) {
			p_row = TextRowList_AddNewRow( &layer->row_list );
		}
		cur_col = p_row->string_len;
	} else { /* 否则,是将文本插入至当前插入点 */
		cur_row = layer->insert_y;
		cur_col = layer->insert_x;
		p_row = TextRowList_GetRow( &layer->row_list, cur_row );
		if( !p_row ) {
			p_row = TextRowList_AddNewRow( &layer->row_list );
		}
	}
	start_row = cur_row;
	ins_x = cur_col;
	ins_y = cur_row;
	/* 如果没有可用的标签栈,则使用临时的标签栈 */
	if( !tag_stack ) {
		is_tmp_tag_stack = TRUE;
		StyleTagStack_Init( &tmp_tag_stack );
		tag_stack = &tmp_tag_stack;
	}
	p_end = wstr + wcslen(wstr);
	for( p=wstr; p<p_end; ++p ) {
		if( layer->is_using_style_tags ) {
			/* 处理样式的结束标签 */ 
			pp = StyleTagStack_ScanEndingTag( tag_stack, p );
			if( pp ) {
				p = pp;
				/* 抵消本次循环后的++p,以在下次循环时还能够在当前位置 */
				--p; 
				continue;
			}
			/* 处理样式标签 */
			pp = StyleTagStack_ScanBeginTag( tag_stack, p );
			if( pp ) {
				p = pp - 1;
				continue;
			}
		}
		
		if( *p == '\r' || *p == '\n' ) {
			/* 如果后面还有 \n,则说明是CR/LF换行模式 */
			if( *p == 'r' ) {
				if( p+1 < p_end && *(p+1) == '\n' ) {
					eol = EOL_CR_LF;
				} else {
					/* 否则是CR换行模式 */
					eol = EOL_CR;
				}
			} else {
				eol = EOL_LF;
			}
			/* 如果没有记录过文本行的矩形区域 */
			if( !rect_has_added ) {
				TextLayer_InvalidateRowsRect( layer, ins_y, -1 );
				rect_has_added = TRUE;
				start_row = ins_y;
			}
			/* 将当前行中的插入点为截点,进行断行 */
			TextLayer_BreakTextRow( layer, ins_y, ins_x, eol );
			need_typeset = TRUE;
			ins_x = 0;
			++ins_y;
			p_row = TextRowList_GetRow( &layer->row_list, ins_y );
			continue;
		}

		char_data.char_code = *p;
		/* 获取当前文本样式数据 */
		char_data.style = StyleTagStack_GetTextStyle( tag_stack );
		/* 更新字体位图 */
		TextChar_UpdateBitmap( &char_data, &layer->text_style );
		TextRow_InsertCopy( p_row, ins_x, &char_data );
		++ins_x;
	}
	/* 更新当前行的尺寸 */
	TextRow_UpdateSize( p_row, layer->text_style.pixel_size );
	if( add_type == TEXT_ADD_TYPE_INSERT ) {
		layer->insert_x = ins_x;
		layer->insert_y = ins_y;
	}
	/* 若启用了自动换行模式,则标记需要重新对文本进行排版 */
	if( layer->is_autowrap_mode || need_typeset ) {
		TaskData_AddUpdateTypeset( &layer->task, cur_row );
	} else {
		TextLayer_InvalidateRowRect( layer, cur_row );
	}
	/* 如果已经记录过文本行矩形区域 */
	if( rect_has_added ) {
		TextLayer_InvalidateRowsRect( layer, start_row, -1 );
		rect_has_added = TRUE;
	}
	/* 如果使用的是临时标签栈,则销毁它 */
	if( is_tmp_tag_stack ) {
		StyleTagStack_Destroy( tag_stack );
	}
	return 0;
}
コード例 #4
0
/** 对文本进行预处理 */
static int TextLayer_ProcessText( LCUI_TextLayer layer, const wchar_t *wstr,
				  int add_type, LinkedList *tags )
{
	EOLChar eol;
	TextRow txtrow;
	TextCharRec txtchar;
	LinkedList tmp_tags;
	LCUI_TextStyle *style = NULL;
	const wchar_t *p_end, *p, *pp;
	int cur_col, cur_row, start_row, ins_x, ins_y;
	LCUI_BOOL is_tmp_tag_stack, need_typeset, rect_has_added;

	if( !wstr ) {
		return -1;
	}
	need_typeset = FALSE;
	rect_has_added = FALSE;
	is_tmp_tag_stack = FALSE;
	/* 如果是将文本追加至文本末尾 */
	if( add_type == TAT_APPEND ) {
		if( layer->rowlist.length > 0 ) {
			cur_row = layer->rowlist.length - 1;
		} else {
			cur_row = 0;
		}
		txtrow = TextLayer_GetRow( layer, cur_row );
		if( !txtrow ) {
			txtrow = TextRowList_AddNewRow( &layer->rowlist );
		}
		cur_col = txtrow->length;
	} else { /* 否则,是将文本插入至当前插入点 */
		cur_row = layer->insert_y;
		cur_col = layer->insert_x;
		txtrow = TextLayer_GetRow( layer, cur_row );
		if( !txtrow ) {
			txtrow = TextRowList_AddNewRow( &layer->rowlist );
		}
	}
	start_row = cur_row;
	ins_x = cur_col;
	ins_y = cur_row;
	/* 如果没有可用的标签栈,则使用临时的标签栈 */
	if( !tags ) {
		is_tmp_tag_stack = TRUE;
		StyleTags_Init( &tmp_tags );
		tags = &tmp_tags;
	}
	p_end = wstr + wcslen( wstr );
	for( p = wstr; p < p_end; ++p ) {
		/* 如果启用的样式标签支持,则处理样式的结束标签 */
		if( layer->is_using_style_tags ) {
			pp = StyleTags_ScanEndingTag( tags, p );
			if( pp ) {
				/* 抵消本次循环后的++p,以在下次循环时还能够在当前位置 */
				p = pp - 1;
				style = StyleTags_GetTextStyle( tags );
				LinkedList_Append( &layer->style_cache, style );
				continue;
			}
			pp = StyleTags_ScanBeginTag( tags, p );
			if( pp ) {
				p = pp - 1;
				style = StyleTags_GetTextStyle( tags );
				LinkedList_Append( &layer->style_cache, style );
				continue;
			}
		}

		if( *p == '\r' || *p == '\n' ) {
			/* 判断是哪一种换行模式 */
			if( *p == '\r' ) {
				if( p + 1 < p_end && *(p + 1) == '\n' ) {
					eol = EOL_CR_LF;
				} else {
					eol = EOL_CR;
				}
			} else {
				eol = EOL_LF;
			}
			/* 如果没有记录过文本行的矩形区域 */
			if( !rect_has_added ) {
				TextLayer_InvalidateRowsRect( layer, ins_y, -1 );
				rect_has_added = TRUE;
				start_row = ins_y;
			}
			/* 将当前行中的插入点为截点,进行断行 */
			TextLayer_BreakTextRow( layer, ins_y, ins_x, eol );
			layer->width = max( layer->width, txtrow->width );
			need_typeset = TRUE;
			++layer->length;
			ins_x = 0;
			++ins_y;
			txtrow = TextLayer_GetRow( layer, ins_y );
			continue;
		}
		txtchar.style = style;
		txtchar.char_code = *p;
		TextChar_UpdateBitmap( &txtchar, &layer->text_style );
		TextRow_InsertCopy( txtrow, ins_x, &txtchar );
		++layer->length;
		++ins_x;
	}
	/* 更新当前行的尺寸 */
	TextLayer_UpdateRowSize( layer, txtrow );
	layer->width = max( layer->width, txtrow->width );
	if( add_type == TAT_INSERT ) {
		layer->insert_x = ins_x;
		layer->insert_y = ins_y;
	}
	/* 若启用了自动换行模式,则标记需要重新对文本进行排版 */
	if( layer->is_autowrap_mode || need_typeset ) {
		TextLayer_AddUpdateTypeset( layer, cur_row );
	} else {
		TextLayer_InvalidateRowRect( layer, cur_row, 0, -1 );
	}
	/* 如果已经记录过文本行矩形区域 */
	if( rect_has_added ) {
		TextLayer_InvalidateRowsRect( layer, start_row, -1 );
		rect_has_added = TRUE;
	}
	/* 如果使用的是临时标签栈,则销毁它 */
	if( is_tmp_tag_stack ) {
		StyleTags_Clear( tags );
	}
	return 0;
}