提交 1090e48f 编写于 作者: B bernard.xiong@gmail.com

fix no image case in listview.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1309 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 cee08f01
......@@ -558,15 +558,25 @@ rt_bool_t rtgui_list_view_event_handler(struct rtgui_widget* widget, struct rtgu
static void rtgui_list_view_calc(struct rtgui_list_view* view)
{
/* get image of first item*/
rtgui_image_t *image;
rtgui_rect_t rect;
rt_uint32_t image_width, image_height;
rt_ubase_t text_width, text_height;
rt_ubase_t item_width, item_height;
if (view->items_count == 0) return;
image = view->items[0].image;
/* get image width and height */
if (view->items[0].image != RT_NULL)
{
image_width = view->items[0].image->w;
image_height = view->items[0].image->h;
}
else
{
image_width = 0;
image_height = 0;
}
rtgui_font_get_metrics(RTGUI_WIDGET_FONT(RTGUI_WIDGET(view)), "HHHHHH", &rect);
text_height = rtgui_rect_height(rect);
......@@ -574,9 +584,9 @@ static void rtgui_list_view_calc(struct rtgui_list_view* view)
rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect);
item_width = (image->w + LIST_MARGIN);
item_width = (image_width + LIST_MARGIN);
if (item_width < (text_width + LIST_MARGIN)) item_width = text_width + LIST_MARGIN;
item_height = image->h + 8 + text_height + LIST_MARGIN;
item_height = image_height + 8 + text_height + LIST_MARGIN;
if (item_width > item_height) item_height = item_width;
else item_width = item_height;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册