Ejemplo n.º 1
0
void
TextLayer_Refresh( LCUI_TextLayer *layer )
/* 标记文本图层中每个字的位图,等待绘制文本图层时进行更新 */
{
	int i, j;
	int rows, len;
	Text_RowData *row_ptr;
	LCUI_CharData *char_ptr;
	LCUI_Rect area;
	
	rows = Queue_Get_Total( &layer->rows_data );
	for(area.y=0,area.x=0,i=0; i<rows; ++i) {
		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 );
			if( !char_ptr ) {
				continue;
			}
			char_ptr->need_update = TRUE; 
		}
		area.height = row_ptr->max_size.h;
		area.width = row_ptr->max_size.w;
		RectQueue_Add( &layer->clear_area, area );
		area.y += row_ptr->max_size.h;
	}
}
Ejemplo n.º 2
0
LCUI_Pos 
TextLayer_Get_Char_PixelPos( LCUI_TextLayer *layer, LCUI_Pos char_pos )
/* 获取显示出来的文字相对于文本图层的坐标,单位为像素 */
{
	LCUI_Pos pixel_pos;
	Text_RowData *row_ptr;
	LCUI_CharData *char_ptr;
	int rows, cols, total;
	
	pixel_pos.x = pixel_pos.y = 0;
	char_pos = TextLayer_Get_Cursor_Pos( layer );
	total = Queue_Get_Total( &layer->rows_data );
	if( char_pos.y >= total ) {
		char_pos.y = total-1;
	}
	if( char_pos.y < 0 ) {
		char_pos.y = 0;
	}
	/* 累加pos.y行之前几行的高度 */
	for( pixel_pos.y=0,rows=0; rows<char_pos.y; ++rows ) {
		row_ptr = Queue_Get( &layer->rows_data, rows );
		if( !row_ptr ) {
			continue;
		}
		pixel_pos.y += row_ptr->max_size.h;
	}
	/* 获取当前行的指针 */
	row_ptr = Queue_Get( &layer->rows_data, rows );
	if( !row_ptr ) {
		pixel_pos.y += 2;
		return pixel_pos;
	}
	/* 获取当前行的文字数 */
	total = Queue_Get_Total( &row_ptr->string ); 
	if( char_pos.x > total ) {
		char_pos.x = total;
	}
	if( char_pos.x < 0 ) {
		char_pos.x = 0;
	}
	/* 累计宽度 */
	for( pixel_pos.x=0,cols=0; cols<char_pos.x; ++cols ) {
		char_ptr = Queue_Get( &row_ptr->string, cols );
		if( !char_ptr ) {
			continue;
		}
		/* 如果设定了屏蔽字符 */
		if( layer->password_char.char_code > 0 ) {
			pixel_pos.x += layer->password_char.bitmap.advance.x;
		} else {
			pixel_pos.x += char_ptr->bitmap.advance.x;
		}
	}
	/* 微调位置 */
	pixel_pos.y += 2;
	return pixel_pos;
}
Ejemplo n.º 3
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");
}
Ejemplo n.º 4
0
int 
Handle_Widget_KeyboardEvent( LCUI_Widget *widget, LCUI_Key key ) 
{
	if( !widget ) {
		return -1;
	}
	
	LCUI_Key *key_data;
	LCUI_Event *event;
	LCUI_Func *func;
	int total, i;
	
	event = Find_Event( &widget->event, EVENT_KEYBOARD );
	if( !event ) {
		return -2;
	}
	
	total = Queue_Get_Total( &event->func_data );
	if( total <= 0 ) {
		return 1;
	}
	key_data = (LCUI_Key*)malloc( sizeof(LCUI_Key) );
	memcpy( key_data, &key, sizeof(LCUI_Key) );
	for (i = 0; i < total; ++i) {
		func = Queue_Get( &event->func_data, i );
		/* 为第二个参数分配了内存,需要在调用完回调函数后销毁它 */
		func->arg[1] = key_data;
		func->destroy_arg[1] = TRUE;
		/* 添加至程序的任务队列 */ 
		AppTask_Custom_Add( ADD_MODE_ADD_NEW, func );
	}
	return 0;
}
Ejemplo n.º 5
0
static LCUI_CharData *
TextLayer_Get_CurChar( LCUI_TextLayer *layer )
/* 获取光标附近的字符数据的指针 */
{
	int total;
	LCUI_Pos pos;
	LCUI_CharData *char_ptr;
	Text_RowData *row_ptr;
	
	pos = TextLayer_Get_Cursor_Pos( layer );
	row_ptr = Queue_Get( &layer->rows_data, pos.y );
	if( !row_ptr ) {
		return NULL;
	}
	char_ptr = Queue_Get( &row_ptr->string, pos.x );
	total = Queue_Get_Total( &row_ptr->string );
	if( !char_ptr ) {
		/* 如果当前光标在这行行尾 */
		if( pos.x == total ) {
			char_ptr = row_ptr->last_char;
		} else {
			return NULL;
		}
	}
	return char_ptr;
}
Ejemplo n.º 6
0
int
TextLayer_Get_RowLen( LCUI_TextLayer *layer, int row )
/* 获取指定行显式文字数 */
{
	int total;
	Text_RowData *row_ptr;
	
	total = Queue_Get_Total( &layer->rows_data );
	if( row > total ) {
		row = total;
	}
	/* 获取当前行的指针 */
	row_ptr = Queue_Get( &layer->rows_data, row );
	if( !row_ptr ) {
		return 0;
	}
	return Queue_Get_Total( &row_ptr->string ); 
}
Ejemplo n.º 7
0
void
TextLayer_Refresh( LCUI_TextLayer *layer )
/* 标记文本图层中每个字的位图,等待绘制文本图层时进行更新 */
{
	uint_t i, j;
	int rows, len;
	Text_RowData *row_ptr;
	LCUI_CharData *char_ptr;
	rows = Queue_Get_Total( &layer->rows_data );
	for(i=0; i<rows; ++i) {
		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 );
			if( char_ptr ) {
				char_ptr->need_update = TRUE;
			}
		}
	}
}
Ejemplo n.º 8
0
BOOL
Have_Task( LCUI_App *app )
/* 功能:检测是否有任务 */
{
	if( !app ) {
		return FALSE; 
	}
	if(Queue_Get_Total(&app->task_queue) > 0) {
		return TRUE; 
	}
	return FALSE;
}
Ejemplo n.º 9
0
static void 
TextLayer_TagStyle_Delete( LCUI_TextLayer *layer, enum_tag_id tag)
/* 将指定标签的样式数据从队列中删除,只删除队列尾部第一个匹配的标签 */
{
	int i, total;
	tag_style_data *p; 
	 
	total = Queue_Get_Total( &layer->tag_buff );
	DEBUG_MSG("delete start, total tag: %d\n", Queue_Get_Total( &layer->tag_buff ));
	if(total <= 0) {
		return;
	}
	for(i=total-1; i>=0; --i) {
		p = Queue_Get( &layer->tag_buff, i );
		if( p->tag == tag ) {
			Queue_Delete( &layer->tag_buff, i );
			break;
		}
	} 
	DEBUG_MSG("delete end, total tag: %d\n", Queue_Get_Total( &layer->tag_buff ));
}
Ejemplo n.º 10
0
static LCUI_TextStyle *
TextLayer_Get_Current_TextStyle ( LCUI_TextLayer *layer )
/* 获取当前的字体样式数据 */
{
	int i, total, equal = 0,flags[MAX_TAG_NUM];
	LCUI_TextStyle *data;
	tag_style_data *p;
	
	data = (LCUI_TextStyle*) malloc (sizeof(LCUI_TextStyle));
	TextStyle_Init( data );
	memset( flags, 0, sizeof(flags) );
	total = Queue_Get_Total( &layer->tag_buff );
	if(total <= 0) {
		free( data );
		return NULL;
	}
	/* 从样式数据队列中获取字体样式数据 */
	for(equal=0,i=total-1; i>=0; --i) {
		p = Queue_Get( &layer->tag_buff, i );
		DEBUG_MSG("tag id: %d\n", p->tag);
		switch( p->tag ) {
		    case TAG_ID_COLOR: 
			if( flags[0] == 0 ) {
				data->_fore_color = TRUE;
				data->fore_color = *((LCUI_RGB*)p->style);
				DEBUG_MSG("color: %d,%d,%d\n", data->fore_color.red,
				 data->fore_color.green, data->fore_color.blue);
				flags[0] = 1;
				++equal;
			}
			break;
		    case TAG_ID_SIZE:
			if( flags[1] == 0 ) {
				PX_PT_t pxpt;
				pxpt = *((PX_PT_t*)p->style);
				data->_pixel_size = TRUE;
				data->pixel_size = pxpt.px;
				flags[1] = 1;
				++equal;
			}
			break;
		    default: break;
		}
		if(equal == MAX_TAG_NUM) {
			break;
		}
	}
	if( equal == 0 ) {
		free( data );
		return NULL;
	}
	return data;
}
Ejemplo n.º 11
0
BOOL 
Cancel_Focus( LCUI_Widget *widget )
/* 
 * 功能:取消指定部件的焦点
 * 说明:该部件会得到EVENT_FOCUS_OUT事件,并且,会将焦点转移至其它部件
 * */
{
	if( !widget || !widget->focus ) {
		return FALSE;
	}
	
	int i, total, focus_pos;
	LCUI_Widget *other_widget, **focus_widget;
	LCUI_Queue *queue_ptr;
	
	if( widget->parent ) {
		focus_widget = &widget->parent->focus_widget;
		queue_ptr = &widget->parent->child;
	} else {
		focus_widget = &LCUI_Sys.focus_widget;
		queue_ptr = &LCUI_Sys.widget_list;
	}
	/* 寻找可获得焦点的其它部件 */
	total = Queue_Get_Total( queue_ptr );
	focus_pos = WidgetQueue_Get_Pos( queue_ptr, *focus_widget );
	for( i=0; i<focus_pos; ++i ) {
		other_widget = Queue_Get( queue_ptr, i);
		if( other_widget && other_widget->visible
		 && other_widget->focus ) {
			Handle_Event( &widget->event, EVENT_FOCUS_IN );
			*focus_widget = other_widget;
			break;
		}
	}
	if( i < focus_pos ) {
		return TRUE;
	}
	/* 排在该部件前面的符合条件的部件没找到,就找排在该部件后面的 */
	for( i=focus_pos+1; i<total; ++i ) {
		other_widget = Queue_Get( queue_ptr, i);
		if( other_widget && other_widget->visible
		 && other_widget->focus ) {
			Handle_Event( &widget->event, EVENT_FOCUS_IN );
			*focus_widget = other_widget;
			break;
		}
	}
	/* 没找到就复位焦点 */
	if( i >= total ) {
		*focus_widget = NULL;
	}
	return TRUE;
}
Ejemplo n.º 12
0
static void
TextLayer_Update_RowSize (LCUI_TextLayer *layer, int row )
/* 更新指定行文本位图的尺寸 */
{
	int total, i;
	LCUI_Size size;
	LCUI_CharData *char_data;
	Text_RowData *row_data;
	LCUI_TextStyle *style;
	
	row_data = Queue_Get( &layer->rows_data, row );
	total = Queue_Get_Total( &row_data->string ); 
	style = TextLayer_Get_Current_TextStyle( layer ); 
	size = Size(0,14);
	if( !style ) {
		if(layer->default_data.pixel_size > 0) {
			size = Size(0, layer->default_data.pixel_size+2);
		}
	} else {
		if(style->pixel_size > 0) {
			size = Size(0, style->pixel_size+2);
		} 
	}
	free( style );
	for( i=0; i<total; ++i ) {
		/* 如果屏蔽字符有效,则使用该字符的数据 */
		if( layer->password_char.char_code > 0 ) {
			char_data = &layer->password_char;
		} else {
			char_data = Queue_Get( &row_data->string, i );
			if( !char_data ) {
				continue;
			}
		}
		size.w += char_data->bitmap.advance.x;
		if( char_data->data ) {
			if( char_data->data->_pixel_size ) {
				if( size.h < char_data->data->pixel_size + 2) {
					size.h = char_data->data->pixel_size + 2;
				}
			} else {
				if( size.h < 14) {
					size.h = 14;
				}
			}
		} else {
			if( size.h < 14) {
				size.h = 14;
			}
		}
	}
	row_data->max_size = size;
}
Ejemplo n.º 13
0
static void
TextLayer_Update_RowSize (LCUI_TextLayer *layer, int row )
/* 更新指定行文本位图的尺寸 */
{
	int total, i;
	LCUI_Size size;
	LCUI_CharData *char_data;
	Text_RowData *row_data;
	LCUI_TextStyle *style;
	
	row_data = Queue_Get( &layer->rows_data, row );
	total = Queue_Get_Total( &row_data->string ); 
	style = TextLayer_Get_Current_TextStyle( layer ); 
	if(style == NULL) {
		if(layer->default_data.pixel_size > 0) {
			size = Size(0, layer->default_data.pixel_size+2);
		} else {
			size = Size(0, 14);
		} 
	} else {
		if(style->pixel_size > 0) {
			size = Size(0,style->pixel_size+2);
		} else {
			size = Size(0,14);
		}
	}
	free( style );
	
	for( i=0; i<total; ++i ) {
		char_data = Queue_Get( &row_data->string, i );
		size.w += char_data->bitmap.width;
		size.w += char_data->bitmap.left;
		//height = char_data->bitmap.top;
		if( char_data->data != NULL ) {
			if( char_data->data->pixel_size != -1 ) {
				if( size.h < char_data->data->pixel_size + 2) {
					size.h = char_data->data->pixel_size + 2;
				}
			} else {
				if( size.h < 14) {
					size.h = 14;
				}
			}
		} else {
			if( size.h < 14) {
				size.h = 14;
			}
		}
	}
	row_data->max_size = size;
}
Ejemplo n.º 14
0
void 
TextLayer_Print_Info( LCUI_TextLayer *layer )
/* 打印文本图层信息 */
{
	int32_t i, j, len, rows;
	Text_RowData *row_ptr;
	LCUI_CharData *char_ptr;
	
	printf( "layer: %p\n", layer );
	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 );
		printf( "row[%d/%d], len: %d\n", j, rows, len );
		for(i=0; i<len; ++i) {
			char_ptr = Queue_Get( &row_ptr->string, i );
			printf( "char code: %d, display: %d\n", 
			char_ptr->char_code, char_ptr->display );
			Print_FontBMP_Info( &char_ptr->bitmap );
		}
	}
	printf("\n\n");
}
Ejemplo n.º 15
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 );
		}
	}
}
Ejemplo n.º 16
0
static int find_widget_data(LCUI_Widget *widget)
{
    graph_data *temp;
    int total, i;
    /* 检查该部件是否用过本函数分配的内存,用过的话,清理它 */
    total = Queue_Get_Total(&picbox_graph_mem);
    for(i=0; i<total; ++i) {
        temp = (graph_data *)Queue_Get(&picbox_graph_mem, i);
        if(temp->widget == widget) {
            return i;
        }
    }
    return -1;
}
Ejemplo n.º 17
0
int 
TextLayer_Text_Add( LCUI_TextLayer *layer, char *new_text )
/* 在光标处添加文本,如有选中文本,将被删除 */
{
	uint_t i, rows;
	TextLayer_Text_Process( layer, new_text );
	TextLayer_Text_GenerateBMP( layer );
	/* 更新每一行文本位图的尺寸 */
	rows = Queue_Get_Total( &layer->rows_data );
	for(i=0; i<rows; ++i) {
		TextLayer_Update_RowSize( layer, i );
	}
	return 0;
}
Ejemplo n.º 18
0
void
TextLayer_Row_Set_End( LCUI_TextLayer *layer, uint_t row, uint_t start_cols )
/* 为指定行设定结束点,结束点及后面的数据将被删除,但不记录残余文本位图区域 */
{
	uint_t total, i;
	Text_RowData *row_data; 
	
	row_data = Queue_Get( &layer->rows_data, row );
	total = Queue_Get_Total( &row_data->string );
	/* 移除多余的数据 */
	for(i=start_cols; i<total; ++i) {
		Queue_Delete( &row_data->string, start_cols ); 
	}
}
Ejemplo n.º 19
0
static int
TextLayer_Update_CurSrcPos( LCUI_TextLayer *layer, int left_or_right )
/* 更新当前光标所在的字符 对应于源文本中的位置 */
{
	int pos, max;
	pos = TextLayer_Get_Cursor_CharPos( layer, left_or_right );
	max = Queue_Get_Total( &layer->text_source_data );
	//printf("pos: %d, max: %d\n", pos, max );
	if( pos == -1 || pos > max ) {
		pos = max;
	}
	if( pos >= 0 ) {
		layer->current_src_pos = pos;
	}
	//printf( "layer->current_src_pos: %d\n", layer->current_src_pos );
	return layer->current_src_pos;
}
Ejemplo n.º 20
0
LCUI_Size 
TextLayer_Get_Size ( LCUI_TextLayer *layer )
/* 获取文本图层的实际尺寸 */
{
	int i, rows;
	LCUI_Size size;
	Text_RowData *p_row; 
	
	rows = Queue_Get_Total( &layer->rows_data );
	for(size.w=0,size.h=0,i=0; i<rows; ++i,++size.h) {
		p_row = Queue_Get( &layer->rows_data, i );
		if( size.w < p_row->max_size.w ) {
			size.w = p_row->max_size.w;
		}
		size.h += p_row->max_size.h;
	}
	return size;
}
Ejemplo n.º 21
0
LCUI_Event *
Find_Event(LCUI_EventQueue *queue, int event_id)
/* 功能:根据事件的ID,获取指向该事件的指针 */
{
	LCUI_Event *event; 
	int i, total;  
	total = Queue_Get_Total(queue);
	if (total > 0) {
		for (i = 0; i < total; ++i) {
			event = (LCUI_Event*)Queue_Get(queue, i);
			if(event->id == event_id) {
				return event;
			}
		}
	}
	
	return NULL;
}
Ejemplo n.º 22
0
static void 
TextLayer_Text_RowBreak ( 
	LCUI_TextLayer *layer, 
	Text_RowData *src, 
	int break_point, 
	Text_RowData *des )
/* 对目标行进行断行处理,也就是将目标行指定位置后面的全部文字转移到另一行 */
{
	static int i, total;
	static LCUI_CharData *char_ptr;
	
	total = Queue_Get_Total( &src->string );
	for(i=break_point; i<total; ++i ) {
		char_ptr = Queue_Get( &src->string, break_point );
		Queue_Add_Pointer( &des->string, char_ptr );
		char_ptr->need_update = TRUE;
		Queue_Delete_Pointer( &src->string, break_point );
	}
}
Ejemplo n.º 23
0
int 
TextLayer_Text_Backspace( LCUI_TextLayer *layer, int n )
/* 删除光标左边处n个字符 */
{
	int i, row_len;
	LCUI_Pos char_pos;
	Text_RowData *row_ptr;
	
	if( layer->read_only ) {
		return -1;
	}
	
	if( n <= 0 ) {
		return -2;
	}
	/* 计算当前光标所在字的位置 */
	char_pos = TextLayer_Get_Cursor_Pos( layer );
	DEBUG_MSG2( "before: %d,%d\n", char_pos.x, char_pos.y );
	for( i=n; char_pos.y>=0; --char_pos.y ) {
		row_ptr = Queue_Get( &layer->rows_data, char_pos.y );
		row_len = Queue_Get_Total( &row_ptr->string );
		
		if( char_pos.x == -1 ) {
			char_pos.x = row_len;
		}
		for( ; char_pos.x>=0 && i>0; --char_pos.x,--i );
		
		if( i<=0 && char_pos.x >= 0 ) {
			break;
		}
	}
	DEBUG_MSG2( "after: %d,%d\n", char_pos.x, char_pos.y );
	if( i>0 ) {
		n -= i;
	}
	DEBUG_MSG2("start_pos: %d,%d, len: %d\n", char_pos.x, char_pos.y, n);
	/* 开始删除文字 */
	_TextLayer_Text_Delete( layer, char_pos, n );
	/* 删除完后,需要将光标向左移动一个位置 */
	TextLayer_Set_Cursor_Pos( layer, char_pos );
	return 0;
}
Ejemplo n.º 24
0
static void
Exec_TextBox_Update( LCUI_Widget *widget )
/* 更新文本框的文本图层 */
{
	LCUI_TextBlock *text_ptr;
	LCUI_TextBox *textbox;
	
	textbox = Get_Widget_PrivData( widget );
	/* 如果缓冲区内有文本块 */
	if( Queue_Get_Total( &textbox->text_block_buff ) > 0 ) {
		/* 获取文本块 */
		text_ptr = Queue_Get( &textbox->text_block_buff, 0 );
		if( text_ptr ) {
			//_DEBUG_MSG("text block: %p, text: %p\n", 
			//	text_ptr, text_ptr->text);
			switch( text_ptr->pos_type ) {
			    case AT_TEXT_LAST:
				/* 将此文本块追加至文本末尾 */
				__TextBox_Text_Append( widget, text_ptr->text );
				break;
			    case AT_CURSOR_POS:
				/* 将此文本块插入至光标当前处 */
				__TextBox_Text_Add( widget, text_ptr->text );
				break;
			    default: break;
			}
		}
		/* 删除该文本块 */
		Queue_Delete( &textbox->text_block_buff, 0 );
		/* 更新滚动条的位置 */
		TextBox_ScrollBar_Update_Pos( widget );
		/* 标记下次继续更新 */
		__Update_Widget( widget );
	}
	/* 更新文本图层的内容 */
	Exec_Update_Widget( TextBox_Get_Label( widget ) );
	/* 更新滚动条的长度 */
	TextBox_ScrollBar_Update_Size( widget );
	/* 更新文本框内的光标 */
	TextBox_Cursor_Update( widget );
}
Ejemplo n.º 25
0
void 
TextLayer_CharLater_Refresh( LCUI_TextLayer *layer, LCUI_Pos char_pos )
/* 刷新指定行中指定字以及后面的字的区域 */
{
	LCUI_Pos pos;
	int i, len;
	Text_RowData *row_ptr;
	LCUI_CharData *char_ptr;
	
	/* 获取该行文字的起点Y轴坐标 */
	for( pos.y=0,i=0; i<char_pos.y; ++i ) {
		row_ptr = Queue_Get( &layer->rows_data, i );
		if( !row_ptr ) {
			continue;
		}
		pos.y += row_ptr->max_size.h;
	}
	row_ptr = Queue_Get( &layer->rows_data, char_pos.y );
	len = Queue_Get_Total( &row_ptr->string );
	/* 获取该字的起点X轴坐标 */
	for( pos.x=0,i=0; i<char_pos.x; ++i ) {
		char_ptr = Queue_Get( &row_ptr->string, i ); 
		if( !char_ptr ) {
			continue;
		}
		pos.x += char_ptr->bitmap.advance.x;
	}
	
	for( i=char_pos.x; i<len; ++i ) {
		char_ptr = Queue_Get( &row_ptr->string, i );
		if( !char_ptr ) {
			continue;
		}
		
		TextLayer_Clear( layer, pos, row_ptr->max_size.h, char_ptr );
		/* 标记该字的位图需要重绘 */
		char_ptr->need_update = TRUE;
		pos.x += char_ptr->bitmap.advance.x;
	}
}
Ejemplo n.º 26
0
wchar_t *
TextLayer_Get_Text( LCUI_TextLayer *layer )
/* 获取文本图层中的文本内容 */
{
	int i, buff_size;
	wchar_t *text_buff;
	LCUI_CharData *char_p;
	buff_size = Queue_Get_Total( &layer->text_source_data );
	if( buff_size <= 0 ) {
		return NULL;
	}
	text_buff = (wchar_t*) malloc( sizeof(wchar_t)*(buff_size+1) );
	printf("print text:\n");
	for( i=0; i<buff_size; ++i ) {
		char_p = Queue_Get( &layer->text_source_data, i );
		printf("%c", char_p->char_code);
		text_buff[i] = char_p->char_code;
	}
	printf("\nend\n");
	text_buff[i] = 0;
	return text_buff;
}
Ejemplo n.º 27
0
int 
Handle_Event(LCUI_EventQueue *queue, int event_id)
/* 
 * 功能:处理指定ID的事件
 * 说明:本函数会将事件队列中与指定ID的事件关联的回调函数 添加至程序的任务队列
 * */
{
	LCUI_Event *event;
	LCUI_Func *func;
	int total, i;
	event = Find_Event(queue, event_id);
	if( !event ) {
		return -1;
	}
	total = Queue_Get_Total(&event->func_data);
	for (i = 0; i < total; ++i) {
		func = Queue_Get(&event->func_data, i);
		/* 添加至程序的任务队列 */ 
		AppTask_Custom_Add(ADD_MODE_REPLACE | AND_ARG_F, func);
	}
	return 0;
}
Ejemplo n.º 28
0
int
TextLayer_Text( LCUI_TextLayer *layer, char *new_text )
/* 设定整个文本图层中需显示的文本,原有选中文本被删除 */
{
	DEBUG_MSG("enter\n"); 
	uint_t i, rows;
	LCUI_TextLayer new_layer;

	TextLayer_Init( &new_layer );
	TextLayer_Text_Set_Default_Style( &new_layer, layer->default_data);
	TextLayer_Using_StyleTags( &new_layer, layer->using_style_tags );
	TextLayer_Text_Process( &new_layer, new_text );
	/* 合并两个文本图层,记录不同字所在区域,等待处理刷新 */
	TextLayer_Merge( layer, &new_layer ); 
	TextLayer_Text_GenerateBMP( layer ); 
	/* 更新每一行文本位图的尺寸 */
	rows = Queue_Get_Total( &layer->rows_data );
	for(i=0; i<rows; ++i) {
		TextLayer_Update_RowSize( layer, i );
	}
	Destroy_TextLayer( &new_layer );  
	DEBUG_MSG("quit\n");
	return 0;
}
Ejemplo n.º 29
0
LCUI_Size 
TextLayer_Get_Size ( LCUI_TextLayer *layer )
/* 获取文本图层的实际尺寸 */
{
	int i, rows;
	LCUI_Size size;
	Text_RowData *p_row; 
	
	rows = Queue_Get_Total( &layer->rows_data );
	for(size.w=0,size.h=0,i=0; i<rows; ++i) {
		p_row = Queue_Get( &layer->rows_data, i );
		if( !p_row ) {
			continue;
		}
		if( size.w < p_row->max_size.w ) {
			size.w = p_row->max_size.w;
		}
		size.h += p_row->max_size.h;
	}
	/* 尺寸稍微搞大一点,因为显示文本光标需要一定空间 */
	size.w += 2;
	size.h += 2;
	return size;
}
Ejemplo n.º 30
0
int 
AppTask_Custom_Add(int mode, LCUI_Func *func_data)
/*
 * 功能:使用自定义方式添加程序任务
 * 用法示例:
 * 在函数的各参数与队列中的函数及各参数不重复时,添加它
 * AppTask_Custom_Add(ADD_MODE_NOT_REPEAT | AND_ARG_F | AND_ARG_S, func_data);
 * 只要函数和参数1不重复则添加
 * AppTask_Custom_Add(ADD_MODE_NOT_REPEAT | AND_ARG_F, func_data);
 * 要函数不重复则添加
 * AppTask_Custom_Add(ADD_MODE_NOT_REPEAT, func_data);
 * 添加新的,不管是否有重复的
 * AppTask_Custom_Add(ADD_MODE_ADD_NEW, func_data);
 * 有相同函数则覆盖,没有则新增
 * AppTask_Custom_Add(ADD_MODE_REPLACE, func_data);
 * */
{
	int total, i;
	/* 先获取程序数据结构体指针 */
	LCUI_App *app;
	LCUI_FuncQueue *queue;
	LCUI_Func *temp = NULL;
	
	if( func_data->id == (LCUI_ID)0 ) {
		app = Get_Self_AppPointer();
	} else {
		app = Find_App( func_data->id );
	}
	if( !app ) {
		return -1;
	}
	queue = &app->task_queue;
	total = Queue_Get_Total(queue);
	/* 如果模式是“添加新的”模式 */
	if( mode == ADD_MODE_ADD_NEW ) {
		Queue_Add(queue, func_data); 
		return 0;
	}
	
	//printf("mode: %d\n", mode);
	for (i = 0; i < total; ++i) {
		//printf("1\n");
		temp = Queue_Get(queue, i);
		/* 如果指针无效,或者函数指针已有记录 */
		if( !temp || temp->func != func_data->func ) {
			continue;
		}
		/* 如果要求的是不重复模式 */ 
		if(Check_Option(mode, ADD_MODE_NOT_REPEAT)) {
			/* 如果要求是第1个参数不能重复 */
			if(Check_Option(mode, AND_ARG_F)) {
				//printf("ADD_MODE_NOT_REPEAT, AND_ARG_F\n");
				//printf("old:%p, new:%p\n", queue->queue[i].arg_f, arg_f);
				/* 如果要求是第2个参数也不能重复 */
				if(Check_Option(mode, AND_ARG_S)) {
					/* 如果函数以及参数1和2都一样 */ 
					if(temp->arg[0] == func_data->arg[0] 
					&& temp->arg[1] == func_data->arg[1]) {
						__destroy_apptask( func_data );
						return -1; 
					}
				} else {/* 否则,只是要求函数以及第1个参数不能全部重复 */
					if(temp->arg[0] == func_data->arg[0]) { 
						__destroy_apptask( func_data );
						return -1; 
					}
				}
			}/* 否则,如果只是要求是第2个参数不能重复 */
			else if(Check_Option(mode, AND_ARG_S)) {
				if(temp->arg[1] == func_data->arg[1] ) {
					__destroy_apptask( func_data );
					return -1; 
				}
			} else {/* 否则,只是要求函数不同 */ 
				__destroy_apptask( func_data );
				return -1; 
			}
		}/* 如果要求的是替换模式 */
		else if(Check_Option(mode, ADD_MODE_REPLACE)) {
			//printf("ADD_MODE_REPLACE\n");
			/* 如果要求是第1个参数相同 */
			if( Check_Option(mode, AND_ARG_F) ) {
				/* 如果要求是第2个参数也相同 */
				if( Check_Option(mode, AND_ARG_S) ) {
					if(temp->arg[0] == func_data->arg[0] 
					&& temp->arg[1] == func_data->arg[1]
					) {
						break; 
					}
				} else {/* 否则,只是要求函数以及第1个参数全部相同 */
					if(temp->arg[0] == func_data->arg[0]) {
				//		printf("ARG_F\n");
						break; 
					}
				}
			}/* 否则,如果只是要求第2个参数不能相同 */
			else if(Check_Option(mode, AND_ARG_S)) {
				if(temp->arg[1] == func_data->arg[1]) {
					break; 
				}
			} else { 
				break; 
			}
		}
	}
	
	if(i == total) {
		Queue_Add(queue, func_data); 
	} else {
		Queue_Replace( queue, i, func_data ); 
	}
	return 0;
}