rt-thread/examples/gui/demo_view_module.c

79 lines
2.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 3ìDò??μ¥£oDCé???ê?í????Yê?
*
* ?a??ày×ó?á?ú′′?¨3?μ?viewé???ê?í???
*/
#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_container_t *_view = RT_NULL;
/* ′ò?a°?¥μ???μ÷oˉêy */
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;
/* ??μ??¥2?μ?workbench */
workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
/* WIN32??ì¨é?oí??êμéè±?é?μ?3?ê??·??|àí */
#ifdef _WIN32
view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
#else
view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
#endif
/* ?£ì???ê?ò??????táD±íêóí?£?ò?ìá1???ó??§????í??????t */
if (rtgui_container_show(RTGUI_CONTAINER(view), RT_TRUE) == RTGUI_MODAL_OK)
{
char path[32], name[8];
/* éè?????t?·??μ?±ê?? */
rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
rt_memset(name, 0, sizeof(name));
/* ??μ?ó|ó??£?éμ?ààDí */
if (rt_strstr(path, ".mo") != RT_NULL || rt_strstr(path, ".so") != RT_NULL)
{
rt_module_open(path);
}
}
/* é?3y ???táD±í êóí? */
rtgui_container_destroy(RTGUI_CONTAINER(view));
rtgui_container_show(_view, RT_FALSE);
}
/* ?¨ó?óú??ê?ó|ó??£?éμ??Yê?êóí? */
rtgui_container_t *demo_view_module(rtgui_workbench_t *workbench)
{
rtgui_rect_t rect;
rtgui_button_t *open_btn;
/* ?è′′?¨ò????Yê?êóí? */
_view = demo_view(workbench, "ó|ó??£?é?Yê?");
/* ìí?óò???°′?¥ */
demo_view_get_rect(_view, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 120;
rect.y2 = rect.y1 + 20;
open_btn = rtgui_button_create("′ò?aó|ó??£?é");
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