/* 更新文本框的样式以及文本图层相关的数据 */ static void TextBox_ExecUpdate( LCUI_Widget *widget ) { LCUI_TextLayer *layer; LCUI_TextBlock *text_ptr; LCUI_TextBox *textbox; textbox = Widget_GetPrivData( widget ); /* 如果缓冲区内有文本块 */ if( Queue_GetTotal( &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_AppendW( 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_UpdatePos( widget ); /* 标记下次继续更新 */ __Widget_Update( widget ); } /* 如果文本框内没有文本,且还未显示占位符,则设置占位符并显示 */ if( TextBox_Text_GetTotalLength( widget ) == 0 && !textbox->show_placeholder ) { layer = TextBox_GetTextLayer(widget); /* 备份文本框内的文本样式以及屏蔽符 */ textbox->textstyle_bak = layer->default_data; textbox->password_char_bak = layer->password_char.char_code; /* 占位符不能被屏蔽,所以设置屏蔽符为0 */ TextLayer_Text_SetPasswordChar( layer, 0 ); /* 文本框内显示占位符 */ TextLayer_TextW( layer, textbox->placeholder.string ); /* 设置占位符的样式 */ TextLayer_Text_SetDefaultStyle( layer, textbox->placeholder_style ); textbox->show_placeholder = TRUE; } TextBox_ExecUpdateStyle( widget ); /* 更新文本框的样式 */ Widget_ExecUpdate( TextBox_GetLabel( widget ) ); /* 更新文本图层的内容 */ TextBox_ScrollBar_UpdateSize( widget ); /* 更新滚动条的长度 */ TextBox_Cursor_Update( widget ); /* 更新文本框内的光标 */ }
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 ); }