rtt-f030/examples/gui/demo_fnview.c

89 lines
2.5 KiB
C
Raw Normal View History

/*
* <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>ʾ<EFBFBD>õ<EFBFBD>view<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>ͼ<EFBFBD><EFBFBD>
*/
#include "demo_view.h"
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/filelist_view.h>
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾѡ<CABE><D1A1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ǩ */
static rtgui_label_t* label;
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>İ<EFBFBD>ť<EFBFBD>ص<EFBFBD><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<63><68><EFBFBD><EFBFBD> */
workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
/* <20><><EFBFBD><EFBFBD>Win32ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ̨<C6BD><CCA8><EFBFBD>IJ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ʵĿ¼λ<C2BC><CEBB> */
#ifdef _WIN32
view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
#else
view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
#endif
/* <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>ʽ<EFBFBD><CABD>ʾ<EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ */
if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK)
{
char path[32];
/* <20><><EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD>гɹ<D0B3>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>·<EFBFBD><C2B7><EFBFBD><EFBFBD> */
rtgui_filelist_view_get_fullpath(view, path, sizeof(path));
/* <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ǩ */
rtgui_label_set_text(label, path);
}
/* ɾ<><C9BE> <20>ļ<EFBFBD><C4BC>б<EFBFBD> <20><>ͼ */
rtgui_view_destroy(RTGUI_VIEW(view));
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>ͼ */
rtgui_view_t* demo_fn_view(rtgui_workbench_t* workbench)
{
rtgui_rect_t rect;
rtgui_view_t* view;
rtgui_button_t* open_btn;
rtgui_font_t* font;
/* Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>12<31><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ */
font = rtgui_font_refer("asc", 12);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ */
view = demo_view(workbench, "FileList View");
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
demo_view_get_rect(view, &rect);
rect.x1 += 5;
rect.x2 -= 5;
rect.y1 += 5;
rect.y2 = rect.y1 + 20;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD>õ<EFBFBD><C3B5>ı<EFBFBD><C4B1><EFBFBD>ǩ */
label = rtgui_label_create("fn: ");
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
RTGUI_WIDGET_FONT(RTGUI_WIDGET(label)) = font;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ͼ<EFBFBD><CDBC>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ */
demo_view_get_rect(view, &rect);
rect.x1 += 5;
rect.x2 = rect.x1 + 80;
rect.y1 += 30;
rect.y2 = rect.y1 + 20;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD><C4BC>б<EFBFBD><D0B1><EFBFBD>ͼ */
open_btn = rtgui_button_create("Open File");
rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(open_btn));
rtgui_widget_set_rect(RTGUI_WIDGET(open_btn), &rect);
RTGUI_WIDGET_FONT(RTGUI_WIDGET(open_btn)) = font;
rtgui_button_set_onbutton(open_btn, open_btn_onbutton);
return view;
}