static void DrawBorder( LCUI_PaintContext paint ) { LCUI_Pos pos; LCUI_Color color; int end_x = paint->rect.width - 1; int end_y = paint->rect.height - 1; pos.x = pos.y = 0; color = RGB( 255, 0, 0 ); Graph_DrawHorizLine( &paint->canvas, color, 1, pos, end_x ); Graph_DrawVertiLine( &paint->canvas, color, 1, pos, end_y ); pos.x = paint->rect.width - 1; Graph_DrawVertiLine( &paint->canvas, color, 1, pos, end_y ); pos.x = 0; pos.y = paint->rect.height - 1; Graph_DrawHorizLine( &paint->canvas, color, 1, pos, end_x ); }
LCUI_API int Graph_DrawBorder( LCUI_Graph *des, LCUI_Border border ) /* 简单的为图形边缘绘制边框 */ { int radius; LCUI_Rect rect; LCUI_Pos start, end; LCUI_Graph des_area; if( !Graph_IsValid(des) ) { return -1; } /* 绘制左上角的圆角,先引用左上角区域,再将圆绘制到这个区域里 */ radius = border.top_left_radius; rect = Rect( 0, 0, radius, radius ); Graph_Quote( &des_area, des, rect ); Graph_Draw_RoundBorder_LeftTop( &des_area , Pos( radius, radius ), radius , border.left_width, border.left_color , TRUE ); Graph_Draw_RoundBorder_TopLeft( &des_area , Pos( radius, radius ), radius , border.top_width, border.top_color , TRUE ); /* 右上角 */ radius = border.top_right_radius; rect = Rect( des->width-radius-1, 0, radius, radius ); Graph_Quote( &des_area, des, rect ); Graph_Draw_RoundBorder_RightTop( &des_area , Pos( 0, radius ), radius , border.right_width, border.right_color , TRUE ); Graph_Draw_RoundBorder_TopRight( &des_area , Pos( 0, radius ), radius , border.top_width, border.top_color , TRUE ); /* 左下角 */ radius = border.bottom_left_radius; rect = Rect( 0, des->height-radius-1, radius, radius ); Graph_Quote( &des_area, des, rect ); Graph_Draw_RoundBorder_LeftBottom( &des_area , Pos( radius, 0 ), radius , border.left_width, border.left_color , TRUE ); Graph_Draw_RoundBorder_BottomLeft( &des_area , Pos( radius, 0 ), radius , border.bottom_width, border.bottom_color , TRUE ); /* 右下角 */ radius = border.bottom_left_radius; rect = Rect( des->width-radius-1, des->height-radius-1, radius, radius ); Graph_Quote( &des_area, des, rect ); Graph_Draw_RoundBorder_RightBottom( &des_area , Pos( 0, 0 ), radius , border.right_width, border.right_color , TRUE ); Graph_Draw_RoundBorder_BottomRight( &des_area , Pos( 0, 0 ), radius , border.bottom_width, border.bottom_color , TRUE ); start.x = border.top_left_radius; start.y = 0; end.x = des->width - border.top_right_radius; /* 绘制上边框 */ Graph_DrawHorizLine( des, border.top_color, border.top_width, start, end.x ); /* 绘制下边的线 */ start.y = des->height - border.bottom_width; end.x = des->width - border.bottom_right_radius; Graph_DrawHorizLine( des, border.top_color, border.bottom_width, start, end.x ); /* 绘制左边的线 */ start.x = start.y = 0; end.y = des->height - border.bottom_left_radius; Graph_DrawVertiLine( des, border.left_color, border.left_width, start, end.y ); /* 绘制右边的线 */ start.x = des->width - border.right_width; start.y = border.top_right_radius; end.y = des->height - border.bottom_right_radius; Graph_DrawVertiLine( des, border.right_color, border.right_width, start, end.y ); /* 边框线绘制完成 */ return 0; }