|
void rtgui_theme_draw_progressbar(struct rtgui_progressbar* bar)
{
/* draw progress bar */
struct rtgui_dc* dc;
struct rtgui_rect rect;
int max = bar->range;
int pos = bar->position;
int left;
rtgui_color_t bc; //背景颜色
/* begin drawing */
dc = rtgui_dc_begin_drawing(&(bar->parent));
if (dc == RT_NULL) return;
bc = RTGUI_DC_BC(dc);
rtgui_widget_get_rect(&(bar->parent), &rect);
/* fill button rect with background color */
bar->parent.gc.background = RTGUI_RGB(212, 208, 200);
/* draw border */
rect.x2 --; rect.y2 --;
rtgui_dc_draw_border(dc, &rect, RTGUI_BORDER_SUNKEN);
/* Nothing to draw */
if (max == 0)
{
rtgui_dc_end_drawing(dc);
return;
}
rect.x2 ++; rect.y2 ++;
left = max - pos;
rtgui_rect_inflate(&rect, -2);
bar->parent.gc.background = RTGUI_RGB(0, 0, 255);
if (bar->orient == RTGUI_VERTICAL)
{
/* Vertical bar grows from bottom to top */
int dy = (rtgui_rect_height(rect) * left) / max;
rect.y1 += dy;
rtgui_dc_fill_rect(dc, &rect);
RTGUI_DC_BC(dc) = bc;
rect.y1 -= dy; rect.y2 = dy+rect.y1; //修正原版垂直显示错误
// rect.y1 -= dy; rect.y2 = dy;
rtgui_dc_fill_rect(dc, &rect);
}
else
{
/* Horizontal bar grows from left to right */
int dx = (rtgui_rect_width(rect) * left) / max;
rect.x2 -= dx;
rtgui_dc_fill_rect(dc, &rect);
RTGUI_DC_BC(dc) = bc;
rect.x1 = rect.x2; rect.x2 += dx;
rtgui_dc_fill_rect(dc, &rect);
}
/* end drawing */
rtgui_dc_end_drawing(dc);
return;
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|