static void Exec_Update_ProgressBar(LCUI_Widget *widget) /* 功能:更新进度条的图形 */ { LCUI_ProgressBar *pb = (LCUI_ProgressBar*)Get_Widget_PrivData(widget); if(Strcmp(&widget->style, "dynamic") == 0) { /* 绘制空槽 */ Draw_Empty_Slot(&widget->graph, widget->size.w, widget->size.h); Set_Widget_Border_Style(widget, BORDER_STYLE_NONE); /* 载入两个图形 */ if(!Graph_Valid(&pb->fore_graph)) Load_Graph_ProgressBar_Fore(&pb->fore_graph); if(!Graph_Valid(&pb->flash_image)) Load_Graph_ProgressBar_Img(&pb->flash_image); Resize_Widget(pb->img_pic_box, Get_Graph_Size(&pb->flash_image)); /* 让图片盒子显示这个图形 */ Set_PictureBox_Image_From_Graph(pb->img_pic_box, &pb->flash_image); } else { Strcpy(&widget->style, "classic"); if(!Graph_Valid(&pb->fore_graph)) Graph_Create(&pb->fore_graph, 10, widget->size.h); Graph_Fill_Color(&pb->fore_graph, RGB(80,80,200)); Graph_Fill_Alpha(&pb->fore_graph, 255); } /* 让图片盒子显示这个图形 */ Set_PictureBox_Image_From_Graph(pb->fore_pic_box, &pb->fore_graph); int width, height; /* 计算进度条的长度 */ width = (widget->size.w - widget->border.left - widget->border.right) * pb->value / pb->max_value + 0.5; height = widget->size.h - widget->border.top - widget->border.bottom; Move_Widget(pb->fore_pic_box, Pos(widget->border.left, widget->border.top)); /* 改变进度条的尺寸 */ Resize_Widget(pb->fore_pic_box, Size(width, height)); }
void TextLayer_Draw( LCUI_Widget *widget, LCUI_TextLayer *layer, int mode ) /* 将文本图层绘制到目标部件的图层上 */ { LCUI_Rect area; LCUI_Pos pos; BOOL draw_all = FALSE; int i, j, n, rows, size; LCUI_RGB color; LCUI_Graph slot; LCUI_CharData *p_data; Text_RowData *p_row; //clock_t start; //start = clock(); //printf("TextLayer_Draw(): enter\n"); /* 如果文本缓存区内有数据 */ if( layer->need_proc_buff ) { __TextLayer_Text( layer ); layer->need_proc_buff = FALSE; } /* 如果需要滚动图层 */ if( layer->need_scroll_layer ) { /* 根据之前记录的偏移坐标,刷新文本图层 */ __TextLayer_OldArea_Erase( widget, layer ); draw_all = TRUE; layer->need_scroll_layer = FALSE; } //nobuff_printf("1, use time: %ld\n", clock() - start ); //start = clock(); Graph_Init( &slot ); /* 先处理需要清空的区域 */ n = Queue_Get_Total( &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 ); Quote_Graph( &slot, &widget->graph, area ); /* 将该区域的alpha通道填充为0 */ Graph_Fill_Alpha( &slot, 0 ); Add_Widget_Refresh_Area( widget, area ); //printf("refresh area: %d,%d,%d,%d\n", //area.x, area.y, area.width, area.height); } //nobuff_printf("2, use time: %ld\n", clock() - start ); //start = clock(); /* 开始绘制文本位图至目标图层上 */ rows = Queue_Get_Total( &layer->rows_data ); for(pos.y=layer->offset_pos.y,i=0; i<rows; ++i) { p_row = Queue_Get( &layer->rows_data, i ); if( !p_row ) { continue; } n = Queue_Get_Total( &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 ) { //nobuff_printf("get, pos: %d, char_ptr: %p, char: %c, draw\n", // i, p_data, p_data->char_code ); p_data->need_update = FALSE; /* 计算区域范围 */ area.x = pos.x + p_data->bitmap.left; area.y = pos.y + p_row->max_size.h-1; area.y -= p_data->bitmap.top; area.height = p_data->bitmap.rows; area.width = p_data->bitmap.width; /* 贴上字体位图 */ FontBMP_Mix( &widget->graph, Pos(area.x, area.y), &p_data->bitmap, color, mode ); /* 记录该区域,以刷新显示到屏幕上 */ Add_Widget_Refresh_Area( widget, area ); } pos.x += p_data->bitmap.advance.x; if( pos.x > widget->size.w ) { break; } } pos.y += p_row->max_size.h; if( pos.y > widget->size.h ) { break; } } //nobuff_printf("3, use time: %ld\n", clock() - start ); //printf("TextLayer_Draw(): quit\n"); }
void TextLayer_Draw( LCUI_Widget *widget, LCUI_TextLayer *layer, int mode ) /* 绘制文本图层 */ { LCUI_Rect area; LCUI_Pos pos; int i, j, n, rows, size; LCUI_RGB color; LCUI_Graph slot; LCUI_CharData *p_data; Text_RowData *p_row; Graph_Init( &slot ); n = Queue_Get_Total( &layer->clear_area ); for(i=0; i<n; ++i) { RectQueue_Get( &area, 0 , &layer->clear_area ); Queue_Delete( &layer->clear_area, 0 ); Quote_Graph( &slot, &widget->graph, area ); /* 将该区域的alpha通道填充为0 */ Graph_Fill_Alpha( &slot, 0 ); Add_Widget_Refresh_Area( widget, area ); } /* 开始粘贴文本位图 */ rows = Queue_Get_Total( &layer->rows_data ); for(pos.y=0,i=0; i<rows; ++i) { p_row = Queue_Get( &layer->rows_data, i ); n = Queue_Get_Total( &p_row->string ); pos.x = 0; // //if( p_row->pos.y != pos.y ) { // RectQueue_Add( &layer->clear_area, Rect(pos.x, pos.y, // p_row->max_size.w, p_row->max_size.h) ); // p_row->pos.y = pos.y; //} for(j=0; j<n; ++j) { p_data = Queue_Get( &p_row->string, j ); if( p_data->data != NULL ) { //if( p_data->data->pixel_size > 0 ) { size = p_data->data->pixel_size; //} else { // size = layer->default_data.pixel_size; //} size += 2; //if( p_data->data->_fore_color ) { color = p_data->data->fore_color; //} else { // color = layer->default_data.fore_color; //} } else { size = layer->default_data.pixel_size + 2; color = layer->default_data.fore_color; } pos.x += p_data->bitmap.left; if( p_data->need_update ) { p_data->need_update = FALSE; area = Rect(pos.x, pos.y, size, size); /* 贴上字体位图 */ FontBMP_Mix( &widget->graph, Pos( pos.x, pos.y + p_row->max_size.h-1 - p_data->bitmap.top), &p_data->bitmap, color, mode ); Add_Widget_Refresh_Area( widget, area ); } pos.x += p_data->bitmap.width; } pos.y += p_row->max_size.h; } }
static void __TextLayer_OldArea_Erase( LCUI_Widget *widget, LCUI_TextLayer *layer ) /* * 功能:擦除文本图层的老区域 * 说明:根据记录的旧偏移坐标,刷新部件区域内的文字所在区域。 * */ { static int i, j, x, y, rows, len; static LCUI_Graph slot; static Text_RowData *row_ptr; static LCUI_CharData *char_ptr; static LCUI_Rect area; Graph_Init( &slot ); rows = Queue_Get_Total( &layer->rows_data ); for(y=layer->old_offset_pos.y,i=0; y<0 && i<rows; ++i) { row_ptr = Queue_Get( &layer->rows_data, i ); if( !row_ptr ) { continue; } if( y + row_ptr->max_size.h >= 0 ) { break; } y += row_ptr->max_size.h; } for(; i<rows; ++i) { row_ptr = Queue_Get( &layer->rows_data, i ); if( !row_ptr ) { continue; } len = Queue_Get_Total( &row_ptr->string ); for(x=layer->old_offset_pos.x,j=0; x<0 && j<len; ++j) { char_ptr = Queue_Get( &row_ptr->string, j ); if( !char_ptr ) { continue; } if( x+char_ptr->bitmap.advance.x >= 0 ) { break; } x += char_ptr->bitmap.advance.x; } area.height = layer->default_data.pixel_size+2; for( ; j<len; ++j ) { char_ptr = Queue_Get( &row_ptr->string, j ); if( !char_ptr ) { continue; } area.y = row_ptr->max_size.h-1; area.y -= char_ptr->bitmap.top; if( area.y + char_ptr->bitmap.rows > area.height ) { area.height = area.y + char_ptr->bitmap.rows; } x += char_ptr->bitmap.advance.x; if( x > widget->size.w ) { break; } } area.x = 0; area.y = y; area.width = x; /* 引用部件图层中的区域 */ Quote_Graph( &slot, &widget->graph, area ); /* 将该区域的alpha通道填充为0 */ Graph_Fill_Alpha( &slot, 0 ); //printf("area: %d,%d,%d,%d\n", area.x, area.y, area.width, area.height); /* 添加刷新区域 */ Add_Widget_Refresh_Area( widget, area ); y += row_ptr->max_size.h; if( y > widget->size.h ) { break; } } }