2012-04-18 23:06:12 +08:00
|
|
|
|
/*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嵥<EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>ʾ
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD>container<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD>ťʱ<EFBFBD>ᰴ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ʾ
|
|
|
|
|
* <EFBFBD>µ<EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>ͼ
|
|
|
|
|
*/
|
|
|
|
|
#include "demo_view.h"
|
|
|
|
|
#include <rtgui/widgets/label.h>
|
|
|
|
|
#include <rtgui/widgets/button.h>
|
|
|
|
|
#include <rtgui/widgets/window.h>
|
|
|
|
|
#include <rtgui/widgets/list_view.h>
|
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
static struct rtgui_application *application = RT_NULL;
|
|
|
|
|
static rtgui_list_view_t *_view = RT_NULL;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
// static rtgui_image_t* return_image = RT_NULL;
|
|
|
|
|
|
|
|
|
|
/* <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
static void listitem_action(rtgui_widget_t *widget, void *parameter)
|
2012-04-18 23:06:12 +08:00
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
char label_text[32];
|
|
|
|
|
rtgui_win_t *win;
|
|
|
|
|
rtgui_label_t *label;
|
|
|
|
|
rtgui_rect_t rect = {0, 0, 150, 80};
|
|
|
|
|
int no = (int)parameter;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_rect_moveto(&rect, 20, 50);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
/* <20><>ʾ<EFBFBD><CABE>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> */
|
|
|
|
|
win = rtgui_win_create(RTGUI_TOPLEVEL(application),
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", &rect, RTGUI_WIN_STYLE_DEFAULT);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rect.x1 += 20;
|
|
|
|
|
rect.x2 -= 5;
|
|
|
|
|
rect.y1 += 5;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ı<EFBFBD>ǩ */
|
|
|
|
|
rt_sprintf(label_text, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> %d", no);
|
|
|
|
|
label = rtgui_label_create(label_text);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
|
|
|
|
|
rtgui_container_add_child(win, RTGUI_WIDGET(label));
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
/* <20><>ģ̬<C4A3><CCAC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> */
|
|
|
|
|
rtgui_win_show(win, RT_FALSE);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>ع<EFBFBD><D8B9>ܵĶ<DCB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
static void return_action(rtgui_widget_t *widget, void *parameter)
|
2012-04-18 23:06:12 +08:00
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_end_modal(RTGUI_CONTAINER(_view), RTGUI_MODAL_OK);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EEB6A8> */
|
|
|
|
|
static struct rtgui_list_item items[] =
|
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
{"<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>1", RT_NULL, listitem_action, (void *)1},
|
|
|
|
|
{"<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>2", RT_NULL, listitem_action, (void *)2},
|
|
|
|
|
{"<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>3", RT_NULL, listitem_action, (void *)3},
|
|
|
|
|
{"<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>4", RT_NULL, listitem_action, (void *)4},
|
|
|
|
|
{"<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>5", RT_NULL, listitem_action, (void *)5},
|
|
|
|
|
{"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", RT_NULL, return_action, RT_NULL},
|
2012-04-18 23:06:12 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>õİ<C3B5>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
static void open_btn_onbutton(rtgui_widget_t *widget, struct rtgui_event *event)
|
2012-04-18 23:06:12 +08:00
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_rect_t rect;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
/* <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>application */
|
|
|
|
|
application = RTGUI_APPLICATION(rtgui_widget_get_toplevel(widget));
|
|
|
|
|
rtgui_widget_get_rect(RTGUI_WIDGET(application), &rect);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD><CDBC> <20><>ָ<EFBFBD><D6B8>Ϊitems */
|
|
|
|
|
_view = rtgui_list_view_create(items, sizeof(items) / sizeof(struct rtgui_list_item),
|
|
|
|
|
&rect, RTGUI_LIST_VIEW_LIST);
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_application_add_container(application, RTGUI_CONTAINER(_view));
|
2012-04-18 23:06:12 +08:00
|
|
|
|
|
2012-08-13 16:32:01 +08:00
|
|
|
|
/* ģʽ<C4A3><CABD>ʾ<EFBFBD><CABE>ͼ */
|
|
|
|
|
rtgui_container_show(RTGUI_CONTAINER(_view), RT_TRUE);
|
|
|
|
|
rtgui_container_destroy(RTGUI_CONTAINER(_view));
|
|
|
|
|
_view = RT_NULL;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>ͼ */
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_container_t *demo_listview_view(void)
|
2012-04-18 23:06:12 +08:00
|
|
|
|
{
|
2012-08-13 16:32:01 +08:00
|
|
|
|
rtgui_rect_t rect;
|
|
|
|
|
rtgui_container_t *container;
|
|
|
|
|
rtgui_button_t *open_btn;
|
|
|
|
|
|
|
|
|
|
container = demo_view("<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>ʾ");
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD>ť */
|
|
|
|
|
demo_view_get_rect(container, &rect);
|
|
|
|
|
rect.x1 += 5;
|
|
|
|
|
rect.x2 = rect.x1 + 80;
|
|
|
|
|
rect.y1 += 30;
|
|
|
|
|
rect.y2 = rect.y1 + 20;
|
|
|
|
|
open_btn = rtgui_button_create("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>");
|
|
|
|
|
rtgui_container_add_child(container, RTGUI_WIDGET(open_btn));
|
|
|
|
|
rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
|
|
|
|
|
rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
|
|
|
|
|
|
|
|
|
|
return container;
|
2012-04-18 23:06:12 +08:00
|
|
|
|
}
|