From d117e5a4fe2388b671f89133daf9066d6d96b09f Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Tue, 2 Feb 2010 00:05:21 +0000 Subject: [PATCH] add return action in listview demo. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@364 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- examples/gui/demo_listview.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/examples/gui/demo_listview.c b/examples/gui/demo_listview.c index 13c0d5cc78..a66a3d1798 100644 --- a/examples/gui/demo_listview.c +++ b/examples/gui/demo_listview.c @@ -5,6 +5,8 @@ #include static rtgui_workbench_t* workbench = RT_NULL; +static rtgui_view_t* _view = RT_NULL; +static rtgui_image_t* return_image = RT_NULL; static void listitem_action(void* parameter) { @@ -33,35 +35,44 @@ static void listitem_action(void* parameter) rtgui_win_show(win, RT_FALSE); } -static struct rtgui_list_item items[] = +static void return_action(void* parameter) +{ + if (_view != RT_NULL) + { + rtgui_view_destroy(_view); + _view = RT_NULL; + } +} + +static const struct rtgui_list_item items[] = { {"列表项1", RT_NULL, listitem_action, (void*)1}, {"列表项2", RT_NULL, listitem_action, (void*)2}, {"列表项3", RT_NULL, listitem_action, (void*)3}, {"列表项4", RT_NULL, listitem_action, (void*)4}, {"列表项5", RT_NULL, listitem_action, (void*)5}, + {"返回", RT_NULL, return_action, RT_NULL}, }; static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) { /* create a file list view */ rtgui_rect_t rect; - rtgui_list_view_t *view; workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget)); rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect); - view = rtgui_list_view_create(items, sizeof(items)/sizeof(struct rtgui_list_item), &rect); - rtgui_workbench_add_view(workbench, RTGUI_VIEW(view)); + _view = rtgui_list_view_create(items, sizeof(items)/sizeof(struct rtgui_list_item), &rect); + rtgui_workbench_add_view(workbench, RTGUI_VIEW(_view)); /* 模式显示视图 */ - rtgui_view_show(RTGUI_VIEW(view), RT_FALSE); + rtgui_view_show(RTGUI_VIEW(_view), RT_FALSE); } rtgui_view_t* demo_listview_view(rtgui_workbench_t* workbench) { rtgui_rect_t rect; - rtgui_view_t* view; + rtgui_list_view_t *view; rtgui_button_t* open_btn; view = demo_view(workbench, "列表视图演示");