rt-thread-official/examples/gui/demo_view_module.c

78 lines
2.0 KiB
C
Raw Normal View History

/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>view<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾͼ<EFBFBD><EFBFBD>
*/
#include "demo_view.h"
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/filelist_view.h>
#include <string.h>
#ifdef RT_USING_MODULE
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
static rtgui_view_t* _view = RT_NULL;
/* <20>򿪰<EFBFBD>ť<EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD> */
static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event)
{
rtgui_filelist_view_t *view;
rtgui_workbench_t *workbench;
rtgui_rect_t rect;
/* <20><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>workbench */
workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
/* WIN32ƽ̨<C6BD>Ϻ<EFBFBD><CFBA><EFBFBD>ʵ<EFBFBD><EFBFBD>ϵij<CFB5>ʼ·<CABC><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#ifdef _WIN32
view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
#else
view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
#endif
/* ģ̬<C4A3><CCAC>ʾһ<CABE><D2BB><EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9A9><EFBFBD>û<EFBFBD>ѡ<EFBFBD><D1A1>ͼ<EFBFBD><CDBC><EFBFBD>ļ<EFBFBD> */
if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
{
char path[32], name[8];
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD>ı<EFBFBD>ǩ */
rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
rt_memset(name, 0, sizeof(name));
/* <20><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
if (rt_strstr(path, ".mo") != RT_NULL || rt_strstr(path, ".so") != RT_NULL)
{
rt_module_open(path);
}
}
/* ɾ<><C9BE> <20>ļ<EFBFBD><C4BC>б<EFBFBD> <20><>ͼ */
rtgui_view_destroy(RTGUI_VIEW(view));
rtgui_view_show(_view, RT_FALSE);
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾӦ<CABE><D3A6>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ */
rtgui_view_t* demo_view_module(rtgui_workbench_t* workbench)
{
rtgui_rect_t rect;
rtgui_button_t* open_btn;
/* <20>ȴ<EFBFBD><C8B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ */
_view = demo_view(workbench, "Ӧ<EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ");
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ť */
demo_view_get_rect(_view, &rect);
rect.x1 += 5; rect.x2 = rect.x1 + 120;
rect.y2 = rect.y1 + 20;
open_btn = rtgui_button_create("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>");
rtgui_container_add_child(RTGUI_CONTAINER(_view), RTGUI_WIDGET(open_btn));
rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
return _view;
}
#endif
#endif