Exemplo n.º 1
0
void 
TextLayer_Text_Set_PasswordChar( LCUI_TextLayer *layer, wchar_t ch )
/* 
 * 设置屏蔽字符,设置后,文本框内的文本都会显示成该字符
 * 如果ch的值为0,则不对文本框里的文本进行屏蔽 
 * */
{
	layer->password_char.char_code = ch;
	TextLayer_Get_Char_BMP( &layer->default_data, &layer->password_char );
	//暂时不进行其它处理
}
Exemplo n.º 2
0
void
TextLayer_Text_GenerateBMP( LCUI_TextLayer *layer )
/* 为文本图层中的文本生成位图,已存在位图的文字将不重新生成 */
{
	BOOL refresh = FALSE;
	LCUI_Pos pos;
	int i, j, len, rows;
	Text_RowData *row_ptr;
	LCUI_CharData *char_ptr;
	
	DEBUG_MSG1("enter\n");
	DEBUG_MSG1("thread: %lu\n", thread_self());
	rows = Queue_Get_Total( &layer->rows_data );
	for( pos.y=0,j=0; j<rows; ++j ) {
		row_ptr = Queue_Get( &layer->rows_data, j );
		len = Queue_Get_Total( &row_ptr->string );
		DEBUG_MSG1("row %d, len: %d\n", j, len);
		for( pos.x=0,i=0; i<len; ++i) {
			char_ptr = Queue_Get( &row_ptr->string, i );
			DEBUG_MSG1("generate FontBMP, get char_ptr: %p, char: %c\n", 
					char_ptr, char_ptr->char_code );
			if( !char_ptr || !char_ptr->display ) {
				DEBUG_MSG1("no display\n");
				continue;
			}
			if( FontBMP_Valid( &char_ptr->bitmap ) ) {
				DEBUG_MSG1("have FontBMP\n");
				if( !refresh ) {
					pos.x += char_ptr->bitmap.advance.x;
					continue;
				}
			} else {
				refresh = TRUE;
				DEBUG_MSG1( "generate FontBMP, char code: %d\n", char_ptr->char_code );
				TextLayer_Get_Char_BMP ( &layer->default_data, char_ptr );
			}
			DEBUG_MSG1( "char_data->bitmap.advance.x: %d\n", char_ptr->bitmap.advance.x );
			TextLayer_Clear( layer, pos, row_ptr->max_size.h, char_ptr );
			char_ptr->need_update = TRUE;
			pos.x += char_ptr->bitmap.advance.x;
		}
		refresh = FALSE;
		/* 更新当前行的尺寸 */
		TextLayer_Update_RowSize( layer, j );
		DEBUG_MSG1("row size: %d,%d\n", row_ptr->max_size.w, row_ptr->max_size.h);
		pos.y += row_ptr->max_size.h;
	}
	DEBUG_MSG1("quit\n");
}
Exemplo n.º 3
0
void
TextLayer_Text_GenerateBMP( LCUI_TextLayer *layer )
/* 为文本图层中的文本生成位图,已存在位图的文字将不重新生成 */
{
	uint_t i, j, len, rows;
	Text_RowData *row_ptr;
	LCUI_CharData *char_ptr;
	
	rows = Queue_Get_Total( &layer->rows_data );
	for(j=0; j<rows; ++j) {
		row_ptr = Queue_Get( &layer->rows_data, j );
		len = Queue_Get_Total( &row_ptr->string );
		for(i=0; i<len; ++i) {
			char_ptr = Queue_Get( &row_ptr->string, i );
			if( char_ptr->display 
			 && FontBMP_Valid( &char_ptr->bitmap ) ) {
				continue;
			}
			DEBUG_MSG( "generate FontBMP, char code: %d\n", char_ptr->char_code );
			TextLayer_Get_Char_BMP ( &layer->default_data, char_ptr );
		}
	}
}
Exemplo n.º 4
0
void
TextLayer_Text_Set_Default_Style( LCUI_TextLayer *layer, LCUI_TextStyle style )
/* 设定默认的文本样式,需要调用TextLayer_Draw函数进行文本位图更新 */
{
	LCUI_Rect area, tmp_area;
	uint_t i, j;
	LCUI_CharData *char_ptr;
	LCUI_TextStyle *old_style;
	Text_RowData *row_ptr;
	int32_t rows, len, old_size;
	
	layer->default_data = style; 
	rows = Queue_Get_Total( &layer->rows_data );
	for(area.y=0,i=0; i<rows; ++i) {
		area.x = 0;
		row_ptr = Queue_Get( &layer->rows_data, i ); 
		len = Queue_Get_Total( &row_ptr->string );
		for(j=0; j<len; ++j) {
			char_ptr = Queue_Get( &row_ptr->string, j ); 
			area.x += char_ptr->bitmap.left; 
			old_style = char_ptr->data;
			if(old_style == NULL) {
				old_size = 12;
				char_ptr->need_update = TRUE; 
			} else {
				if(old_style->pixel_size > 0) {
					old_size = old_style->pixel_size;
				} else {
					old_size = 12;
				}
			}
			/* 若有属性是缺省的 */
			if(!old_style->_pixel_size) {
				old_style->pixel_size = style.pixel_size;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_style) {
				old_style->style = style.style;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_family) {
				strcpy(old_style->family, style.family);
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_weight) {
				old_style->weight = style.weight;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_back_color) {
				old_style->back_color = style.back_color;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_fore_color) {
				old_style->fore_color = style.fore_color;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_decoration) {
				old_style->decoration = style.decoration;
				char_ptr->need_update = TRUE; 
			} 
			if(char_ptr->need_update) {
				tmp_area.x = area.x;
				tmp_area.y = area.y + old_size+2 - char_ptr->bitmap.top;
				tmp_area.width = char_ptr->bitmap.width;
				tmp_area.height = char_ptr->bitmap.rows; 
				/* 记录之前字体位图所在区域,等待刷新 */
				RectQueue_Add( &layer->clear_area, tmp_area ); 
				area.x += char_ptr->bitmap.width;
				/* 重新获取字体位图 */
				FontBMP_Free(&char_ptr->bitmap); 
				TextLayer_Get_Char_BMP ( &layer->default_data, char_ptr );
			} else {
				area.x += char_ptr->bitmap.width;
			}
		}
		area.y += row_ptr->max_size.h; 
	} 
}
Exemplo n.º 5
0
void
TextLayer_Text_Set_Default_Style( LCUI_TextLayer *layer, LCUI_TextStyle style )
/* 设定默认的文本样式,需要调用TextLayer_Draw函数进行文本位图更新 */
{
	LCUI_Pos pos;
	LCUI_CharData *char_ptr;
	LCUI_TextStyle *old_style;
	Text_RowData *row_ptr;
	int rows, len, i, j;
	
	layer->default_data = style; 
	rows = Queue_Get_Total( &layer->rows_data );
	for(pos.y=0,i=0; i<rows; ++i) {
		row_ptr = Queue_Get( &layer->rows_data, i ); 
		len = Queue_Get_Total( &row_ptr->string );
		for(pos.x=0,j=0; j<len; ++j) {
			char_ptr = Queue_Get( &row_ptr->string, j );
			if( !char_ptr ) {
				continue;
			}
			old_style = char_ptr->data;
			if( !old_style ) {
				char_ptr->need_update = TRUE; 
				goto skip_style_cmp;
			}
			/* 若有属性是缺省的 */
			if(!old_style->_pixel_size) {
				old_style->pixel_size = style.pixel_size;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_style) {
				old_style->style = style.style;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_family) {
				strcpy(old_style->family, style.family);
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_weight) {
				old_style->weight = style.weight;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_back_color) {
				old_style->back_color = style.back_color;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_fore_color) {
				old_style->fore_color = style.fore_color;
				char_ptr->need_update = TRUE; 
			}
			if(!old_style->_decoration) {
				old_style->decoration = style.decoration;
				char_ptr->need_update = TRUE; 
			} 
skip_style_cmp:;
			if(char_ptr->need_update) {
				TextLayer_Clear( layer, pos, row_ptr->max_size.h, char_ptr );
				pos.x += char_ptr->bitmap.advance.x;
				/* 重新获取字体位图 */
				FontBMP_Free(&char_ptr->bitmap); 
				TextLayer_Get_Char_BMP ( &layer->default_data, char_ptr );
			} else {
				pos.x += char_ptr->bitmap.advance.x;
			}
		}
		pos.y += row_ptr->max_size.h; 
		TextLayer_Update_RowSize( layer, i );
	}
}